2

以下を使用して EditText を作成しました。

    <style name="foredits">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:singleLine">true</item>
    <item name="android:maxLines">1</item>
    <item name="android:scrollHorizontally">true</item>
    <item name="android:typeface">monospace</item>
    <item name="android:imeOptions">actionNext</item>
    </style>

EditText を作成するときに、layout_weight、id、および id を他の属性として入れます。次の場合に EditText を水平方向にスクロールしたいと思います。

a.hint が edittext の境界内に収まらない b.text が入力され、テキストが edittext の境界の右端を超える

これは横スクロールしていないので、ScrollingMovementMethodでも試してみました

   edit_mul.setHorizontalScrollBarEnabled(true);
   edit_mul.setMovementMethod(new ScrollingMovementMethod());

これも機能していないようです。これを機能させるにはどうすればよいですか?

4

2 に答える 2

1

あなたのコードは良さそうです。垂直スクロールバーxmlに対して次のことを行いました <TextView android:id="@+id/response_sms_textView3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="20dp" android:background="@color/White" android:gravity="center" android:lines="8" android:maxLines="8" android:scrollbars="vertical" <!-- include --> android:text="@string/without_account_response_sms_tv3" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/Black" />

コード tv3.setMovementMethod(新しい ScrollingMovementMethod()); // 含む

ただし、これを ScrollView レイアウト内に配置すると、機能しない場合があります。ありがとう

于 2013-10-03T07:02:28.623 に答える
0

edittext では次のパラメータを使用できます。

edittext.setFocusable(false);
edittext.setClickable(false);
edittext.setFocusableInTouchMode(false);
edittext.setEnabled(true);
edittext.setKeyListener(null);
edittext.setHorizontallyScrolling(true);

したがって、望ましい動作として機能します。

于 2014-08-21T06:58:39.627 に答える