1

ここで、またはこのレイアウトで何週間も抱えている問題を尋ねてきたので、今回は必要なものの写真を示します。

ここに画像の説明を入力

画面の下部に常にEditText と Button が必要です(キーボードが表示されるときは、キーボードの下にとどまらず、キーボードの上に表示する必要があります)。空き画面の残りの部分は、スクロール可能な TextView にする必要があります。

編集: これは、Romain の指摘に従って、現在のコードです。スクロール以外はすべて期待どおりに機能します。TextView はスクロール可能である必要がありますが、そうではありません。修正方法は?

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

    <TextView
        android:id="@+id/consola"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scrollbars = "vertical"
        android:height="0dip"
        android:layout_weight="1.0"/>

    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom">

        <EditText 
        android:id="@+id/editText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

        <Button
            android:text="Conectar"
            android:id="@+id/boton"
            android:label="@string/enviar_string"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </Button>
    </LinearLayout>
</LinearLayout>
4

3 に答える 3

5

あなたのレイアウトは複雑すぎます。これはあなたがすべきことの要約版です:

LinearLayout width=fill_parent height=fill_parent orientation=vertical
    TextView width=fill_parent height=0dip layout_weight=1.0
    EditText width=fill_parent height=wrap_content
    Button width=fill_parent height=wrap_content

TextView の layout_weight が重要です。親 LinearLayout に、この TextView に残りのすべての空きスペースを与えるように指示します (これが、高さが 0dip に設定されている理由でもあります)。

于 2011-11-24T17:49:49.803 に答える
1

私はついに自分で解決策を見つけました:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView   
android:id="@+id/scroller"  
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:height="0dip"
android:layout_weight="1.0">  

    <TextView
        android:id="@+id/consola"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"/>

</ScrollView>

<EditText 
    android:id="@+id/editText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom">

    <Button
        android:text="Conectar"
        android:id="@+id/boton"
        android:label="@string/enviar_string"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </Button>
</LinearLayout>

于 2011-11-28T16:00:19.277 に答える
0

isScrollContainerTextView で true に設定すると、ソフトキーボードを表示する必要がある場合にサイズを変更できます。マニフェストのアクティビティにandroid:windowSoftInputMode=" adjustResize " を追加します。

少し古いドキュメント

于 2011-11-24T22:38:43.080 に答える