0

The following code show the UI a1.png that I hoped, but there are some problems with the code, the bottom toolbar buttons will not show when I add some listview items just like 2.png.

I hope that the bottom toolbar button always show, and ListView control can acroll to show the hidden items when I add some listview items.

BTW, I hope btnAddNumber button near the ListView control, and the position of btnAddNumber will be move down when add the listview item, and btnAddNumber maybe hide when I add many listview items, but I can scroll screen to make it show.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"    
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/border_ui"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="aaaaa"
        ads:loadAdOnCreate="false" />    

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:textSize="16sp" />

     <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:gravity="center"
            android:orientation="horizontal" >

        <Button
            android:id="@+id/btnAddNumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add Number" />       
    </LinearLayout>        

    <TextView
        android:id="@+id/tvOnlyFullSpace"
        android:layout_width="wrap_content"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:text="" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="#DCDCDC"
        android:gravity="center"
        android:orientation="horizontal" >

       <Button
            android:id="@+id/btnBack"
            style="@style/myTextAppearance"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Back" />


        <Button
            android:id="@+id/btnNext"
            style="@style/myTextAppearance"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Next" />

        <Button
            android:id="@+id/btnCancel"
            style="@style/myTextAppearance"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Cancel" />

    </LinearLayout>

</LinearLayout>

a1.png
enter image description here

a2.png
enter image description here

HelloCW
  • 843
  • 22
  • 125
  • 310

1 Answers1

1

You can use a RelativeLayout

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

    <View
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"

      /> 
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btnBack"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Back" />

        <Button
            android:id="@+id/btnNext"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Next" />

        <Button
            android:id="@+id/btnCancel"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:text="Cancel" />
    </LinearLayout>

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/adView"
        android:layout_above="@+id/btnAddNumber"
        android:layout_alignParentLeft="true" >

    </ListView>

        <Button
            android:id="@+id/btnAddNumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/linearLayout1"
            android:layout_centerHorizontal="true"
            android:text="Add Number" />

</RelativeLayout>

snap

Now the 3 buttons are fixed at the bottom (always) of the screen. Above which you have another Add Number above which you have listview.

There is some space above listview for the view ( in your case adView);

enter image description here

Edit:

You can also add buttons as a footer to listview.

How to add a footer in ListView?

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256