1

In my app, I would like to have a TextView DIRECTLY below a ListView. So if the ListView ends somewhere half of the screen, the TextView must be right there in the middle of the screen. But if the ListView covers more then the screen, so you have to scroll trough it, you also have to scroll for the TextView as its below the ListView. Have you got any idea on how to do that?

Thanks in advance!

Xander
  • 5,487
  • 14
  • 49
  • 77
  • you need the textview below the listview or whether it should be visible all the time even if the listview covers more than the screen? – G_S Oct 27 '12 at 13:52
  • 1
    Make the `TextView` the last entry in the `ListView`. – bobnoble Oct 27 '12 at 13:52

4 Answers4

3

you may add a footer to your ListView. you can use the example provided in this link

View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);
Community
  • 1
  • 1
ColdFire
  • 6,764
  • 6
  • 35
  • 51
1

You can add a header and footer view to a ListView. Both views then scroll with the other list items. Check addFooterView().

Flo
  • 27,355
  • 15
  • 87
  • 125
1

you can use following layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ListView
    android1:id="@+id/listView1"
    android1:layout_width="match_parent"
    android1:layout_height="wrap_content"
    android1:layout_alignParentLeft="true"
    android1:layout_alignParentTop="true" >

</ListView>

   <TextView
       android1:id="@+id/textView1"
       android1:layout_width="wrap_content"
       android1:layout_height="wrap_content"
       android1:layout_alignParentBottom="true"
       android1:layout_below="@+id/listView1"
       android1:layout_centerHorizontal="true"
       android1:text="TextView" />

</RelativeLayout>
  • Hi, I downvoted this answer because I was angry at someone. Could you edit it, by adding some space somewhere so I can vote up? – Vitali Pom Oct 31 '19 at 16:56
0

Use layout_weight to set the weight of the view.

 <ListView android:layout_width="fill_parent"
 android:layout_height="0dp" 
 android:layout_weight="8"
 android:id="@+id/ght" /> 

 <EditText android:id="@+id/eld" 
  android:layout_height="wrap_content"
  android:layout_width="fill_parent"
  android:layout_weight="2">
 </EditText>
MKB
  • 7,587
  • 9
  • 45
  • 71
  • You too, "Hi, I downvoted this answer because I was angry at someone. Could you edit it, by adding some space somewhere so I can vote up?" – Vitali Pom Oct 31 '19 at 16:57