0

Here is screen shoot of my mobile app. How can i adjust button "Manage Category" in center at the bottom because this black space at bottom not seems good.

enter image description here

Here is my layout file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listCategory"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="0.9"
        android:background="#FFFFFF"
        android:gravity="top" />

    <Button
        android:id="@+id/btnManageCategory"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:onClick="onButtonClick"
        android:text="Manage Category" 
        android:gravity="center"
        />

</LinearLayout>

4 Answers4

0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listCategory"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:background="#FFFFFF"
        android:gravity="top" />
    <View
         android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1">
    </View>

    <Button
        android:id="@+id/btnManageCategory"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
         android:layout_weight="1"
        android:onClick="onButtonClick"
        android:text="Manage Category" 
        android:gravity="center"


        />

</LinearLayout>
Pratik Dasa
  • 7,439
  • 4
  • 30
  • 44
0

Try this :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

<ListView
    android:id="@+id/listCategory"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="0.9"
    android:background="#FFFFFF"
    android:gravity="top" />

<Button
    android:id="@+id/btnManageCategory"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:onClick="onButtonClick"
    android:text="Manage Category" 
    android:gravity="center"
    />

</LinearLayout>
Harish Godara
  • 2,388
  • 1
  • 14
  • 28
0

You might try using weights. You may have to play with the numbers to get what you want but give the ListView a weight of say .8 and .2 for the Button. Make sure to give the height a value of 0dp for both. Something like

  <ListView
    android:id="@+id/listCategory"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="0.8"
    android:background="#FFFFFF"
    android:gravity="top" />

<Button
    android:id="@+id/btnManageCategory"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:onClick="onButtonClick"
    android:text="Manage Category" 
    android:gravity="center"
    android:layout_weight="0.2"   
    />
codeMagic
  • 44,549
  • 13
  • 77
  • 93
0
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listCategory"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#FFFFFF" />

    <Button
        android:id="@+id/btnManageCategory"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="onButtonClick"
        android:text="Manage Category"
        android:gravity="center"/>

</LinearLayout>
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67