alignParentBottom not used - android

I had a layout which used LinearLayouts instead of RelativeLayouts. I want to add the borderless buttons to my layouts as shown here: How to create standard Borderless buttons (like in the design guidline mentioned)?
So, to use this, I had to change my LinearLayouts to RelativeLayouts. This has worked fine for the most part. However, when I try to use the alignParentBottom for one of the RelativeLayouts it doesn't work - it just overlaps with one of my other buttons.
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".xxx" >
<com.xxx.xxx.customedittext
android:id="#+id/qn_et_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:drawableRight="#drawable/delete"
android:hint="#string/qn_et_title_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="5dp" />
<com.xxx.xxx.customedittext
android:id="#+id/qn_et_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/qn_et_title"
android:drawableRight="#drawable/delete"
android:hint="#string/qn_et_body_hint"
android:inputType="textCapSentences|textMultiLine" />
<CheckBox
android:id="#+id/qn_cb_ongoing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_et_body"
android:text="#string/qn_cb_ongoing" />
<Button
android:id="#+id/qn_b_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_cb_ongoing"
android:text="#string/qn_b_create" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="?android:attr/dividerVertical" />
<View
android:id="#+id/ViewColorPickerHelper"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="?android:attr/dividerVertical" />
<Button
android:id="#+id/BtnColorPickerCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/cancel" />
<Button
android:id="#+id/BtnColorPickerOk"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/ok" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
EDIT: This is updated code. The ScrollView overlaps the 48dp RelativeView:
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:paddingBottom="3dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".QuickNoteFragment" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/qn_et_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/qn_et_title_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="5dp" />
<EditText
android:id="#+id/qn_et_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/qn_et_title"
android:hint="#string/qn_et_body_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="10dp" />
<CheckBox
android:id="#+id/qn_cb_ongoing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_et_body"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/qn_cb_ongoing" />
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="?android:attr/dividerVertical" />
<View
android:id="#+id/ViewColorPickerHelper"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="?android:attr/dividerVertical" />
<Button
android:id="#+id/qn_b_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/cancel" />
<Button
android:id="#+id/qn_b_create"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#string/qn_b_create" />
</RelativeLayout>
</RelativeLayout>

Use the following properties on the ScrollView:
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true">
<!-- rest of the code -->
</RelativeLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/bottom"
android:layout_alignParentTop="true" >
<!-- rest of the code -->
</ScrollView>
<RelativeLayout>

Related

ListView overlaps textview and background image in android

I am trying to design layout but its not rendering properly. Background logo is not visible at all. When phone goes to landscape mode then textview below listview is not visible.
Below is my xml.
<ScrollView 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:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#E0ECF8" >
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/note1"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/banner640" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/menu_title"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8" >
</ListView>
<View
android:id="#+id/View2_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#android:id/list"
android:layout_marginTop="5dp"
android:background="#80000000" />
</RelativeLayout>
</ScrollView>
You problem may come from using ListView inside ScrollView. You should avoid it. To overcome your problem, I think you can set a specific height for your ListView or using a vertical LinearLayout to add row views programmatically.
Using a ListView to make it not scroll is extremely expensive and goes against the whole purpose of ListView. You should NOT do this. Just use a LinearLayout instead. - from Romain Guy - the developer who write ListView in GG.
ok the problem is there with your definition, just define your LinearLayout below View (which is belowListView). check this
<RelativeLayout 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:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="MEnu"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8" >
</ListView>
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginTop="10dp"
android:background="#E0ECF8"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="Nofghnjfgjtyjjyjdtyjte"
android:textColor="#000"
android:textSize="25sp" />
</LinearLayout>
</RelativeLayout>
output :
May be that is what you need?
UPDATE:
<ScrollView 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:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#E0ECF8" >
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8"
android:layout_above="#+id/note1Wrapper_note1">
</ListView>
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/note1"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/banner640" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/menu_title"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<View
android:id="#+id/View2_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#android:id/list"
android:layout_marginTop="5dp"
android:background="#80000000" />
</RelativeLayout>
</ScrollView>

How to give space between two images in listiview?

I am using listiview for my application,in my listiview i set something like this
listitem1(Image)
listitem2(Image+Image)
Now issue is in my second row i want to get space between two images,but it is not working,following is my xml layout and screen shot of my output
listview_view
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F3"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/lnrsearchviews"
android:layout_below="#+id/imgshead"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/rect_search"
>
<!--<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/searchs"
android:layout_gravity="center_vertical"
/>-->
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/autosearchbyname"
android:hint="Search"
/>
</LinearLayout>
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txt_shopbydept"
android:text="Shop By Departments"
android:textSize="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_below="#+id/lnrsearchviews"
/>-->
<ListView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/list_menu"
android:layout_below="#+id/lnrsearchviews"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="20dp"
android:dividerHeight="8dp"
android:divider="#f3f3f3"
></ListView>
</RelativeLayout>
list_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:id="#+id/btntest"
android:background="#drawable/ab"
android:orientation="horizontal"
>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="180dp"
android:id="#+id/id"
android:background="#drawable/heads"
android:layout_weight="1.17">
<RelativeLayout
android:layout_height="40dp"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:padding="2dp"
android:text="abd"
android:id="#+id/txt_allproductsname"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:padding="2dp"
android:text="abddd"
android:id="#+id/txt_allproductsquty"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Mygetview
http://pastie.org/10289187#5
Try this as your list_item and use set visibility of the second ImageView to gone when you need to show only one image.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/first_imageview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#9ff0"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/second_imageview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#9ff0"
android:src="#drawable/ic_launcher" />
</LinearLayout>

how to set listview in half screen on Map view in android

<?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="55dip"
android:background="#00ad9a"
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="9dip"
android:layout_marginTop="9dip"
android:src="#drawable/backbutton" />
<ImageView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="3dip"
android:layout_marginTop="3dip"
android:gravity="center"
android:src="#drawable/centertext" />
</RelativeLayout>
<LinearLayout
android:id="#+id/Llayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/contact_relMainHeader"
android:background="#android:color/transparent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/Rlayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/contact_linearHeader1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.lociiapp.MapWrapperLayout
android:id="#+id/map_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<TextView
android:id="#+id/lastSeenDatetextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
android:background="#07000000"
android:gravity="bottom">
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
<TextView
android:id="#+id/typing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
</com.lociiapp.MapWrapperLayout>
</LinearLayout>
<com.lociiapp.utils.RoundedImageView
android:id="#+id/recciverImage"
android:layout_width="60dip"
android:layout_height="60dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/imge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/llout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Rlayout"
android:gravity="bottom"
android:orientation="horizontal" >
<EditText
android:id="#+id/txt_inputText"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_weight="0.86"
android:background="#drawable/backgroundline"
android:focusableInTouchMode="true"
android:hint="Write Message"
android:paddingLeft="20dp"
android:textColor="#ababab" />
<Button
android:id="#+id/btn_Send"
android:layout_width="79dp"
android:layout_height="50dip"
android:background="#ededed"
android:text="Send"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
This is my XMl i am trying to display listview in half screen and then it should scroll its item basically i want to display only 3 item .
currently my screen is looking like this
while i have to display list-view only half screen please tell suggest me where am doing wrong i have to display listview half screen in which i want to display only 3 item ...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#07000000"
android:gravity="bottom"
android:orientation="horizontal" >
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
<TextView
android:id="#+id/typing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
replace this and set ur height of linear layout according to given screen and enjoy!!!

Three children on RelativeLayout does not get place to be shown

I am trying to show four direct children on a Relative Layout where first one is a EdiText (in 'gone' visibility) and second one is LinearLayout with a TextView and ImageView and third is a ListView and fourth is another LinearLayout.
ListView gets over all children. I am posting below the code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollview"
android:background="#drawable/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.antoinecampbell.gcmdemo.GcmActivity$PlaceholderFragment">
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/recepient" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</RelativeLayout>
Now I tried using LinearLayout with scrollview inside it, it's now not scrolling the listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="visible"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
The ListView will go over other elements because you've not given it any relative positions. In a relative layout, every element will be default appear at (0,0) (ie the top left corner of the view) unless it's given a layout_below, layout_alignBottom etc parameter to determine where it's drawn.
So in this case, you 'resumably want the ListView to have android:layout_below="#id/LinearLayout1 and the bottomview similarly android:layout_below="#id/listMessages.
Here is the xml as per your requirement.
<?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:layout_gravity="center"
android:gravity="center" >
<EditText
android:id="#+id/edNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:inputType="phone"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edNumber"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="linear layout text" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llBottom"
android:layout_below="#id/llLayout" >
</ListView>
<LinearLayout
android:id="#+id/llBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ababab"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Bottom Bar text" />
</LinearLayout>
</RelativeLayout>

How to fill The Android screen with views and layouts?

I have a Relative Layout Containing following Views and Nested Relative Layouts. For Some devices there is a blank space left at the bottom of the screen. I want to equitably distribute the space to the nested views and viewgroups() to fill the Screen.
<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="fill_parent"
android:orientation="vertical"
android:background="#color/tdmubiobgd"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MasterActivity$DummySectionFragment" >
<Button
android:id="#+id/ScanButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Scan" />
<ImageView
android:id="#+id/scan_adsView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:layout_alignLeft="#id/ScanButton"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#drawable/ads" />
<RelativeLayout
android:id="#+id/scan_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_adsView"
android:layout_below="#id/scan_adsView"
android:layout_marginTop="10px"
android:orientation="horizontal" >
<ImageView
android:id="#+id/Scan_Image"
android:layout_width="72px"
android:layout_height="72px"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/Scan_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/Scan_Image"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/Scan_DName"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:gravity="right"
android:text="DName "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<TextView
android:id="#+id/Scan_Sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Scan_Name"
android:layout_toRightOf="#+id/Scan_Age"
android:text="Male"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Scan_Age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Scan_Sex"
android:layout_alignBottom="#+id/Scan_Sex"
android:layout_alignLeft="#+id/Scan_Name"
android:text="30"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<ImageView
android:id="#+id/scan_level1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_header"
android:layout_below="#+id/scan_header"
android:scaleType="fitXY"
android:src="#drawable/l1warning" />
<RelativeLayout
android:id="#+id/scan_master"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_level"
android:layout_below="#id/scan_level1"
android:layout_marginTop="10px"
android:orientation="horizontal" >
<TextView
android:id="#+id/scan_mname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MinionRush"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/scan_mdetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_mname"
android:layout_below="#+id/scan_mname"
android:text="DoodlePlay"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/scan_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scan_mdetails"
android:text="DartRace"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/scan_alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:src="#drawable/alarm" />
</RelativeLayout>
<ImageView
android:id="#+id/scan_level2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/scan_master"
android:layout_below="#id/scan_master"
android:scaleType="fitXY"
android:layout_marginTop="10px"
android:src="#drawable/toempty" />
<Gallery
android:id="#+id/scan_gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scan_level2"
android:layout_marginTop="10px"
android:layout_alignParentLeft="true" />
<ImageView
android:id="#+id/faq"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scan_gallery"
android:layout_centerHorizontal="true"
android:layout_marginTop="10px"
android:scaleType="fitXY"
android:src="#drawable/faq" />
</RelativeLayout>
Use the following :
<?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:orientation="vertical"
android:background="#ffffff">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#556677">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#664411"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#997766">
</RelativeLayout>
</LinearLayout>
Hope this will help you....
use linear layout as your parent layout and give weights to all layouts.
Here is a XML for your question
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
use
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
use linear layout and add
android:layout:weight="1"
in every tag..
if you want to use the Relative layout then,it is better that you should get the screen dimension and divide it into four, if you have four views
Refer this link for getting screen size

Categories

Resources