android:layout_alignParentRight="true" does nothing - android

I have an ImageView which I've set to android:layout_alignParentRight="true" however it does not appear on the right side of the screen and I'm not sure why (it is the white square appearing centered horizontally in the screenshot below).
I understand this can only be used with a RelativeLayout - but I've used one - so I'm not sure exactly why this is happening.
<?xml version="1.0" encoding="utf-8"?>
<com.example.project.DragLayer xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:id="#+id/drag_layer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/black" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<GridView
android:id="#+id/image_grid_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:background="#color/grid_background"
android:gravity="center"
android:horizontalSpacing="2dip"
android:numColumns="#integer/num_columns"
android:stretchMode="columnWidth"
android:verticalSpacing="2dip" />
<RelativeLayout
android:id="#+id/bottom_part"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_weight="0.2"
android:background="#android:color/black"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="#+id/button_add_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="onClickAddImage"
android:text="Add image" />
<com.example.project.DeleteZone
android:id="#+id/delete_zone_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/delete_zone" />
<FrameLayout
android:id="#+id/image_source_frame"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="0.5" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/sqwhite"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:layout_weight="1" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/sqwhite"
android:layout_marginRight="5dp" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/editText1"
android:layout_marginRight="5dp"
android:text=""
android:textColor="#android:color/white" />
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</com.example.project.DragLayer>

The one glaring thing that jumps out at me is the redefinition of the xmlns, which any compiler doesn't like and may prevent proper generation of the layout. When I removed that and some of your dead code and tried running this, the "sqwhite" appeared on the right side. See if fixing these items helps:
Your first LinearLayout redefines the XML Namespace, which is an error. This could be what's preventing the XML from compiling properly.
Other minor items:
layout_weight only applies to children of LinearLayouts, so having them in other ViewGroups is unnecessary. Remove them from image_source_frame and its children
Having bottom_part use layout_centerHorizontal in a vertical LinearLayout is redundant and should also be removed.
Having layout_alignParentRight in your RelativeLayout is useless, since only children of RelativeLayouts can use it. Please remove.
Maybe I'm missing it from the code you provided, but where is the white square actually coming from? You didn't set an android:src attribute to the ImageView. So is it possible that the actual sqwhite is in the right place, and that that white square represents something else?
EDIT: I've re-pasted your code here, with the items I listed removed. Maybe this will help:
<?xml version="1.0" encoding="utf-8"?>
<com.example.project.DragLayer xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drag_layer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/black" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<GridView
android:id="#+id/image_grid_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:background="#color/grid_background"
android:gravity="center"
android:horizontalSpacing="2dip"
android:numColumns="#integer/num_columns"
android:stretchMode="columnWidth"
android:verticalSpacing="2dip" />
<RelativeLayout
android:id="#+id/bottom_part"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_weight="0.2"
android:background="#android:color/black"
android:weightSum="1.0" >
<Button
android:id="#+id/button_add_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="onClickAddImage"
android:text="Add image" />
<com.example.project.DeleteZone
android:id="#+id/delete_zone_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/delete_zone" />
<FrameLayout
android:id="#+id/image_source_frame"
android:layout_width="fill_parent"
android:layout_height="80dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:layout_marginRight="5dp" >
<ImageView
android:id="#+id/sqwhite"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:src="#android:drawable/ic_delete" /> <!-- for testing -->
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/sqwhite"
android:layout_marginRight="5dp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/editText1"
android:layout_marginRight="5dp"
android:text=""
android:textColor="#android:color/white" />
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</com.example.project.DragLayer>

Related

How to remove borders in Activity android

I can't understand what a reason of these borders in my Activity.
Could you help me to remove it please?
I have found out advice to replace match_parent with fill_parent, but it doesn't help of course.
I have marked red only places in which you can see the problem, but it seems that there are borders fill all height of screen at left and right.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context="AppName.NewNoteActivity">
<ScrollView android:id="#+id/newNoteScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<VideoView
android:id="#+id/newNoteVideoView"
android:layout_height="200dp"
android:layout_width="fill_parent"
/>
<EditText
android:layout_width="220dp"
android:layout_height="wrap_content"
android:inputType="text"
android:id="#+id/inputName"
android:layout_marginTop="20dp"
/>
<TimePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/timePicker"
android:layout_marginTop="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/inputDate"
android:layout_marginTop="20dp"
android:clickable="true"
android:onClick="onClickInputDate"
android:text="#string/activity_new_note_helloText_inputDate"
/>
<Button
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="Save"/>
</LinearLayout>
</ScrollView>

how to partition Activity in 3 parts for different Controls

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/contact_relMainHeader"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#16A180"
android:padding="5dp" >
<ImageView
android:id="#+id/contact_btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="#drawable/scrol" />
<ImageView
android:id="#+id/contact_btnLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="#drawable/lock" />
<ImageView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:src="#drawable/centertext" />
</RelativeLayout>
</RelativeLayout>
This is My Screen currently looking Like this .http://snag.gy/kwjAn.jpg i have to make of layout 3 partition vertically first for Google map ,Second for Name Display and , Third one for chat window actually i have make lay Out like this 10 part divide in to 4:2:4 3segement http://snag.gy/exrsu.jpg like this Layout. please help am unable to do this .
Try this ......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/contact_relMainHeader"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#16A180"
android:padding="5dp" >
<ImageView
android:id="#+id/contact_btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/contact_btnLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<LinearLayout
android:layout_below="#+id/contact_relMainHeader"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_weight="40"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#ff0000"
android:orientation="vertical"
>
</LinearLayout>
<LinearLayout
android:layout_weight="20"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#000000"
>
</LinearLayout>
<LinearLayout
android:layout_weight="40"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:background="#ffff00"
>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Fragments will help you get the desired result. I can explain to you the logic without writing the code(...you need to put that effort). Your layout should have 3 fragments
The mapfagment can be at the top. Mapfragments
This can be followed by the fragment that contains a textview.
And the last one will contain your chat window.

TextView does not show or cuts text in 2.3, works fine in 3.0+

So this is a brain teaser, I have a ListView with a custom layout, the issue is that the values are not showing correctly(See pics). First of all, all values in the list in 3.0+ are populated fine.
In 2.3 & 2.2 the first item in the list is properly populated but from the second on the text is cut off or doesn't display at all.
Another thing is that if I try to scroll slowly up or down the values start showing but obviously this is not the behavior needed.
This is the xml layout for each item in the list
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="horizontal"
android:paddingTop="8dip">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="#+id/toptext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/bottomtext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="7"
android:orientation="vertical" >
<TextView
android:id="#+id/value1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="right"
android:layout_marginRight="6dip"
android:layout_weight="1"
android:textSize="20sp" />
<TextView
android:id="#+id/value2"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="right"
android:layout_marginRight="6dip"
android:layout_weight="1"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/value3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal" >
<ImageView
android:id="#+id/valu4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ImageView>
</LinearLayout>
<LinearLayout
android:id="#+id/value5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="horizontal" >
<ImageView
android:id="#+id/value6"
android:layout_width="wrap_content"
android:layout_height="10dp" >
</ImageView>
<ImageView
android:id="#+id/value7"
android:layout_width="wrap_content"
android:layout_height="10dp" >
</ImageView>
<ImageView
android:id="#+id/value8"
android:layout_width="wrap_content"
android:layout_height="10dp" >
</ImageView>
</LinearLayout>
<LinearLayout
android:id="#+id/value9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/value10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:textSize="8dp"
android:textStyle="bold" >
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextHere"
android:textSize="8dp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="#+id/Value11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:textSize="8dp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
</LinearLayout>
And this is the xml for the main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:theme="#android:style/Theme.Black.NoTitleBar">
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_weight="7"
android:scrollbars="none"
android:transcriptMode="normal">
</ListView>
</LinearLayout>
Thanks for any help in advance, sorry I cannot post pics until I reach level 10 (noob here <--)
Pic links added!
Before scrolling:
http://imgur.com/BYVgfEI
After scrolling:
http://imgur.com/P3rj4w6
Ok, so I know that with the information provided in the question there was no way of figuring out the answer. But just in case someone else experiences this strange behavior this is what was causing the issue.
in the onCreate method i had the line:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
causing the textviews to cut or not show the text unless the view was scrolled. The action bar was not implement until API 11, and 2.3 is only 9. But there was no waring compiling or deploying the project.
Solution replace the line above with:
if (android.os.Build.VERSION.SDK_INT >=android.os.Build.VERSION_CODES.HONEYCOMB) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
}
After the change, the text in the listview was displaying correctly.

Complex android layout (overlapping, left/right align, center align)

I have to create the following layout on an Android device:
The requirements are as follows:
First layout which occupies the whole screen (fill_parent);
Second (at the bottom of the screen) overlays the first one and has the following formats:
3 columns;
occupies the whole screen width;
arrows are aligned left and right sides, and text area is resized based on screen width;
I've tried numerous things, but since I'm new to the Android world, I had no success yet.
Here is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:id="#+id/RootView">
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:id="#+id/mapImageView" />
<LinearLayout
android:id="#+id/bottomArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="#+id/adsArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<ImageButton
android:src="#drawable/leftArrow"
android:id="#+id/btnPrev"
android:layout_alignParentRight="true"
android:layout_marginLeft="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:src="#drawable/rightArrow"
android:layout_alignParentRight="true"
android:layout_marginRight="0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnNext" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
but the text doesn't seem to be center aligned, nor resized to the screen width:
Does someone has a clue?
Thanks.
Use this code for your required layout...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/linear2" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<RelativeLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<ImageButton
android:id="#+id/leftButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/rightButton1"
android:layout_toRightOf="#+id/leftButton1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:id="#+id/rightButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
Please find the code below. Also, do not use multiple viewgroup for simple layout solution.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RootView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/mapImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#android:drawable/ic_menu_gallery" />
<RelativeLayout
android:id="#+id/adsArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<ImageButton
android:id="#+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="#drawable/leftArrow" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is some summary text" />
</LinearLayout>
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/rightArrow" />
</RelativeLayout>
</RelativeLayout>

How to align textviews when listviews are null?

So here is my problem:
I have here an edittext, 2 textviews and 2 listviews. The functionality of this activity is a search activity. when you type a certain word or phrase, there can be a result in either in Tools or Articles. My main problem is, when both tools and articles cannot find that word, I want the one in the red box, be something like this:
but I don't know how. I tried hiding the listviews but still I failed. So can you help me with this matter? Here is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/navbar_search"
android:paddingLeft="5dp" >
<ImageView
android:id="#+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/btn_back" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/violet"
android:padding="5dp" >
<EditText
android:id="#+id/editTextSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_search"
android:paddingLeft="35dp" >
</EditText>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editTextSearch"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:src="#drawable/search" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/blue"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/textArticlesResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/label_articles"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:textStyle="bold" />
<ListView
android:id="#+id/listViewArticlesResult"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/textArticlesResult"
android:cacheColorHint="#color/white"
android:scrollbars="none"
android:visibility="gone" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#color/blue"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/textToolsResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/label_tools"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:textStyle="bold" />
<ListView
android:id="#+id/listViewToolsResult"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/textToolsResult"
android:cacheColorHint="#color/white"
android:scrollbars="none" >
</ListView>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="46dp" >
<ImageView
android:id="#+id/tabHome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="#string/desc"
android:scaleType="fitXY"
android:src="#drawable/tab_home_unselected" />
<ImageView
android:id="#+id/tabFb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="#string/desc"
android:scaleType="fitXY"
android:src="#drawable/tab_fb_unselected" />
<ImageView
android:id="#+id/tabSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="#string/desc"
android:scaleType="fitXY"
android:src="#drawable/tab_search_selected" />
<ImageView
android:id="#+id/tabFaves"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="#string/desc"
android:scaleType="fitXY"
android:src="#drawable/tab_myfaves_unselected" />
<ImageView
android:id="#+id/tabSettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="#string/desc"
android:scaleType="fitXY"
android:src="#drawable/tab_settings_unselected" />
</LinearLayout>
</LinearLayout>
What I've done is to programatically hide the view. In my case, I wanted to hide the TextView when the content provider returned an empty string. Do this by:
TextView address = (TextView) findViewById(R.id.address);
address.setVisibility(View.GONE);
Don't forget to re-enable the TextView when you get a non-empty string by:
address.setVisibility(View.VISIBLE);
Note that View.INVISIBLE will only make the TextView disappear. View.GONE makes it so the TextView isn't even accounted for in the layout.

Categories

Resources