5

ウィンドウの高さを埋めるEditTextが必要です。私はこれを使用しています:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:inputType="textMultiLine"
    android:textColor="@android:color/white" />

</ScrollView>

しかし、私が得るのは1行のEditTextだけで、これは、戻るボタンを複数行入力して何かを書くと、より長くスクロール可能になります。行番号を設定できることはわかっていますが、この場合はさまざまなデバイスで機能するはずであり、すべてのデバイス(おそらく)の行数は異なります。

デバイスの高さを強制的に満たすにはどうすればよいですか?

任意のヒント?

4

5 に答える 5

4

(ScrollViewなしで)使用してみてください:

<EditText
    android:id="@+id/text_editor"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="#ff0000"
    android:gravity="top|left"
    android:textColor="@android:color/white" />
于 2012-06-20T13:47:40.973 に答える
3

EditTextにこれを設定してみてください、私は同じことをしました、これはうまくいくでしょう。

<EditText
android:id="@+id/text_editor"
android:layout_width="match_parent"
**android:layout_height="wrap_content"**
android:background="#ff0000"
android:gravity="top|left"
android:inputType="textMultiLine"
android:textColor="@android:color/white" />

また、これを使用して、必要な行数を正確に設定することもできます。

android:lines="number of Lines"
于 2012-06-20T14:07:28.810 に答える
0

コードに追加できる場合は、次のようになります。

EditText et = new EditText(this);
l.addView(et, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 100));

ここで、100は100dpの幅になることを意味します。これlLayoutあなたが持っているかもしれない(ScrollViewあなたの場合)あなたがで得ることができるものですR.layout.name_of_the_scroll_view

よくわかりませんが、高さのプロパティを入れてみてくださいWRAP_CONTENT

于 2012-06-20T13:42:55.920 に答える
0
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <EditText
        android:id="@+id/editText1"
        android:scrollbars="vertical" <-----------
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:gravity="top|left"
        android:ems="10"
        android:text=" example text" />

</RelativeLayout>

Javaコードでこれを設定します.....

ed1 = (EditText) findViewById(R.id.editText1);
ed1.setMovementMethod(new ScrollingMovementMethod()); <--------

すべてのデバイスで動作します。

これがお役に立てば幸いです。

于 2012-06-20T14:00:07.347 に答える
0

私のコードそれは私のために働きます。

<?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="match_parent"
android:background="#ffffff"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView20"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/img_desc1"
    android:src="@drawable/num74_head_payakorn" />

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <EditText
        android:id="@+id/edtPayakorn"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textSize="22sp"
        android:clickable="false"
        android:cursorVisible="false"
        android:editable="false"
        android:enabled="true"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="top|left"
        android:scrollbars="vertical"
        android:inputType="textMultiLine" />
    </TableRow>
</LinearLayout>
于 2013-03-15T15:59:20.867 に答える