私は最初の2行に2つのEditTextを持つテーブルレイアウトと、他の行のカスタムキーボードのように動作するボタンの束を持っています。 (簡略化のため、xmlの最初の行のボタンだけが含まれています) EditTextビューは、android:scrollbars="vertical"
でスクロール可能に設定されています。カスタムキーボードのボタンを押すと、値が入力文字列に追加され、次にEditText.setText()
メソッドでテキストが設定されます。私の問題は、テキストが長すぎると、完全なEditTextビューも次の行にリサイズすることです。さもなければ、デフォルトのアンドロイドキーボードで同じことを行うのは、チャームのように機能し、サイズ変更せずに次の行に進み、右側にスクロールバーを表示します。
は、ここでXMLキーボード入力の代わりに "setText"を使用すると、EditTextビューのサイズが変更される
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip">
<EditText
android:layout_weight="1"
android:scrollbars="vertical"
android:layout_height="match_parent"
android:id="@+id/input"
android:layout_span="2"
android:text="Type an expression to begin..." />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dip">
<EditText
android:layout_weight="1"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:id="@+id/output"
android:layout_span="2"
android:text="Real time calculation"/>
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF0000" />
<TableRow
android:id="@+id/tableRow3"
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp" >
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_clear"
android:text="C" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_divide"
android:text="/" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_multiply"
android:text="*" />
<Button
android:layout_width="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:background="@drawable/button_custom_bg"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="@+id/button_delete"
android:text="DEL" />
</TableRow>
</TableLayout>
setText()
方法の問題点は何ですか? さらに、EditTextをサイズ変更しなくても、両方のEditTextに背景画像を追加して、ビューに合わせてサイズを変更したいとします。
任意の提案は、これはあなたの問題を解決する使用
希望の出力画像を追加 –