0

私のレイアウトでは、ヘッダー、リストビュー、およびフッターが必要TextViewです。最大5行までサイズ変更可能であるTextView必要があります。Facebookチャットを考えてみてください。ここには、友達の名前が付いた青いヘッダー、中央のコンテンツペイン、下にあるテキストボックスがあり、入力すると大きくなります。

[header]     a fragment that takes up about 50dp
[content]
[content]
[content]
[content]    something like a ViewGroup with a ListView in it
[content]
[content]
[content]
[footer]     a ViewGroup that contains an EditText and Buttons

いろいろなレイアウト設定を試しましたが、うまくいきません。フッターがすべてのスペースを占めるか、コンテンツがフッターをカバーします。

これが私がこれまでに持っているものです:

<LinearLayout ...>

    <!-- Slot to put Header fragment in -->
    <FrameLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Here's where the content goes. This is supposed to be a ListView
         inserted as a fragment -->
    <FrameLayout
        android:id="@+id/content"
        ... />

    <include
        android:id="@+id/footer"
        ... />

</LinearLayout>

との値を何に設定すればよいかわからないためlayout_width、値を空のままにしました。layout_height

更新 当初、問題はとに設定されているためだと思いましたがEditText、ハードコードされた高さのボタンを1つだけ削除しようとしましたが、インサートがすべてをカバーしていました。私も設定してみましたが、カバーしただけですmaxLines=5TextMultiline<footer below="content">contentfooter

4

3 に答える 3

1

問題は、footer含まれているレイアウトが別のものであるということでしたRelativeLayout。レイアウトには、フッターレイアウトが画面全体を占めるように設定するfooter要素が含まれています。layout_alignParentBottom="true"なぜそうなるのか分かりませんが、そういうことが起こります。

于 2012-09-26T02:09:28.723 に答える
0

これをチェックしてください...私はそれが役立つことを願っています。現時点では、Valuesフォルダーにarray.xmlを定義し、ListViewの空のエントリをいくつか示しています。コードで処理する必要があります。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


        <TextView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="HEADER" />    

        <ListView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:entries="@array/chats"
            android:layout_weight="1">

        </ListView>


        <EditText 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lines="5"
            android:inputType="textMultiLine"
            android:hint=" Please enter your Chat" />  

</LinearLayout>
于 2012-09-21T13:46:50.363 に答える
0

このようなUIを作成するには、レイアウトを作成します

header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

<TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="5dp"
            android:text="xyz"
            android:textSize="10dp" />
</LinearLayout>

フッターの場合:

footer.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

<EditText

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="5dp"
            android:text="xyz"
            android:textSize="10dp" />
</LinearLayout>

あなたが言ったようにlistViewを含む別のレイアウトを作成します:main.xml

<RelativeLayout xmlns: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" >
 **<include layout="@layout/header.xml" android:layout_alignParentTop="true"/>**   
<ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        >
    </ListView>
 **<include layout="@layout/footer.xml" android:layout_below="@+id/listview" android:layout_alignParentBottom="true"/>**   
</RelativeLayout>
于 2012-09-20T10:40:17.510 に答える