I wanted to make a layout with 3 LinearLayouts
. In the 2nd LinearLayout
I would have a ListView
and the 3rd LinearLayout
I would have an EditText
and Button
at the bottom. This was my attempt:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fresco="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/view_post" android:layout_width="fill_parent" android:layout_height="200dp" android:background="@color/com_facebook_blue"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/view_status"/> </LinearLayout> <LinearLayout android:id="@+id/view_comments" android:layout_below="@+id/view_post" android:layout_width="match_parent" android:layout_height="250dp"> <ListView android:id="@+id/lv_comments_feed" android:layout_width="fill_parent" android:layout_height="wrap_content"> </ListView> </LinearLayout> <LinearLayout android:layout_below="@+id/view_comments" android:id="@+id/send_message" android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentBottom="true" android:orientation="horizontal" > <EditText android:id="@+id/write_comment" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:layout_weight="5" android:gravity="top|left" android:inputType="textMultiLine" android:scrollHorizontally="false" /> <Button android:id="@+id/send_comment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:text="send" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> </RelativeLayout>
Now the design looks great but when I load the app on my phone, I have 2 problems:
-
I don't want to hardcode the LinearLayout heights. I have looked into
layout_weight
but I can't seem to have theselayout_weights
work without running into the 2nd problem below: -
When I click the
EditText
, theEditText
is hidden even though I have declaredandroid:windowSoftInputMode="adjustResize|stateHidden"
in my activity and I'm not sure why that's happening. Also, theEditText
andButton
are not directly at the bottom of the screen which is what I would want. Any help is appreciated, thanks!
No comments:
Post a Comment