IntelliJ Amiya
IntelliJ Amiya

Reputation: 75778

Button not showing up on screen

I have created an app where i showing listview with an image and text . I add Button in the end of page . But this is not showing on screen .I am new in android .How can i solve this ?

Here is my UI XML Code :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp"
tools:context=".MainActivity" 
android:background="@drawable/maps">

<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/WAYLF"
  android:gravity="center"
  android:textSize="22sp" />

<ListView
    android:id="@+id/list_view"
    android:dividerHeight="4dp"
    android:cacheColorHint="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<Button
 android:layout_width="match_parent"
 android:layout_height="35dp"
 android:text="@string/NEXT"
 android:background="@android:color/holo_green_light"
 android:layout_marginTop="25dp" />

Upvotes: 0

Views: 1277

Answers (2)

Lucian Novac
Lucian Novac

Reputation: 1265

Put into RelativeLayout parrent then set a static marginBottom that is equal to height of the button for listview and after that put the button in bottom of the parrent

Upvotes: 0

Hamid Shatu
Hamid Shatu

Reputation: 9700

Set android:layout_height="0dip" and android:layout_weight="1" to ListView as below...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/maps"
    android:orientation="vertical"
    android:padding="8dp"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/WAYLF"
        android:textSize="22sp" />

    <ListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:cacheColorHint="@android:color/transparent"
        android:dividerHeight="4dp" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:layout_marginTop="25dp"
        android:background="@android:color/holo_green_light"
        android:text="@string/NEXT" />

</LinearLayout>

Upvotes: 1

Related Questions