Creating An Android Layout With 2 Resizing Views
In my layout, I need a header, a list-view, and a footer with a TextView. The TextView needs to be resizable to up to 5 lines. Think facebook chat, where you have the blue header w
Solution 1:
The problem was that the footer
layout included is another RelativeLayout
. The footer
layout contains elements that set layout_alignParentBottom="true"
, which made the footer layout take up the entire screen. I have no idea why it would do that, but that's what happens.
Solution 2:
For creating a UI like this create a layout
header.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:paddingLeft="5dp"android:text="xyz"android:textSize="10dp" /></LinearLayout>
for footer:
footer.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:paddingLeft="5dp"android:text="xyz"android:textSize="10dp" /></LinearLayout>
Create another layout that will contain listView as you said : main.xml
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_gravity="center"android:gravity="center"android:orientation="vertical" >
**<includelayout="@layout/header.xml"android:layout_alignParentTop="true"/>**
<ListViewandroid:id="@+id/listview"android:layout_width="fill_parent"android:layout_height="wrap_content"android:clickable="true"
></ListView>
**<includelayout="@layout/footer.xml"android:layout_below="@+id/listview"android:layout_alignParentBottom="true"/>**
</RelativeLayout>
Solution 3:
check this...I hope it helps. At the moment I have defined an array.xml in Values folder with some empty entries for ListView. You will have to handle it with code.
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="HEADER" /><ListViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:entries="@array/chats"android:layout_weight="1"></ListView><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:lines="5"android:inputType="textMultiLine"android:hint=" Please enter your Chat" /></LinearLayout>
Post a Comment for "Creating An Android Layout With 2 Resizing Views"