0

List-Row.xml : structure of one row of the file. So, I want to add a button to add a new user which stays the bottom of the screen no matter how many rows have been added to the code.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/list_selector"
    android:orientation="horizontal"
    android:padding="5dip" >

<!--  ListRow Left sied Thumbnail image -->

    <LinearLayout android:id="@+id/thumbnail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="3dip"
    android:layout_alignParentLeft="true"
    android:background="@drawable/image_bg"
    android:layout_marginRight="5dip">

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:src="@drawable/account_image"/>

</LinearLayout>

<!-- Title Of Song-->
<TextView
    android:id="@+id/account_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/thumbnail"
    android:layout_toRightOf="@+id/thumbnail"
    android:text="Account one"
    android:textColor="#040404"
    android:typeface="sans"
    android:textSize="15dip"
    android:textStyle="bold"/>

<!-- Rightend Arrow -->
<ImageView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/arrow"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"/>

Era Dwivedi
  • 41
  • 1
  • 10

3 Answers3

0
<LinearLayout android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical">
<ListView android:id="@android:id/mylist"
      android:layout_height="0dip"
      android:layout_width="match_parent"
      android:layout_weight="1" />
<Button android:id="@+id/mybtn" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

</LinearLayout>
Titto Jose
  • 72
  • 1
  • 3
0

https://stackoverflow.com/a/10083342/4784128

This worked best for me. Placing the button relative to the list using android:layout_alignParentBottom="true" did the trick

Community
  • 1
  • 1
Era Dwivedi
  • 41
  • 1
  • 10
0

Try something like this,

       <RelativeLayout   
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ignoreGravity="@+id/addNewUserButton"
            android:descendantFocusability="blocksDescendants">

            <ListView
                android:id="@+id/your_listview"
                />

            <RelativeLayout
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true">

                    <ImageButton
                        android:id="@+id/addNewUserButton"
                        android:background=""  
                        android:paddingTop="10dp"
                        android:paddingRight="12dp"
                        android:paddingBottom="12dp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>
                </RelativeLayout>
        </RelativeLayout>
dhun
  • 643
  • 7
  • 13