Reputation: 4470
My app contains ListView
and TextView
. I want to arrange TextView
to below of ListView
. I tried with below code, but TextView
disappeared.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/android:list"
android:text="@string/hello"
/>
</RelativeLayout>
Thanks.
Upvotes: 0
Views: 117
Reputation: 1641
Try this code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<ListView android:id="@+id/android:list"
android:layout_height="match_parent"
android:gravity="center"
android:cacheColorHint="#ffffffff"
android:layout_width="match_parent"
android:layout_above="@+id/add_workout_all_workout_list"></ListView>
<TextView android:layout_width="wrap_content"
android:id="@+id/add_workout_all_workout_list" android:layout_height="wrap_content"
android:text="textView" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
Upvotes: 1
Reputation: 8304
If you insist on using RelativeLayout, do the following:
Should work.
Upvotes: 0
Reputation: 3193
U can place Textview below listview by 2 ways.
Hope u get what i say.
Upvotes: 0
Reputation: 2047
Try LinearLayout
as below. I think this will produce what you're after. This layout will always put the TextView below the list at the bottom of the view.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
Upvotes: 2
Reputation: 16558
Try replacing your XML with this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/android:list"
android:text="@string/hello"
/>
</LinearLayout>
You don't want to use the relative layout at all. If you need it specifically, simply replace the LinearLayout with it.
Upvotes: 3
Reputation: 10349
You used fill_parent for both width and height of listview as below. So it will occupy entire screen. So that the Text view is invisible. Please change it to fixed height according to your device resolution.
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Replace fill_parent with 100px or other in below line and try once
android:layout_height="fill_parent" />
Upvotes: 0