いくつかのデータを表示する必要がTableLayout
あります。各行には2つの列があります。最初の列にはフィールド名があり、2番目の列にはフィールド値があります。いずれかのフィールドをクリックすると、が表示されますEditText
。私はを使用してそれを行いますViewSwitcher
。
TextView
/の文字数が少ない場合EditText
は問題ありませんが、最初の行がいっぱいになると、最初の列(フィールド名)が狭くなり、2番目の列が広くなります。私はそれが起こらないようにしたいのです。列を常に同じサイズにしたいのです。
これは私のレイアウトです:
<TableLayout
android:id="@+id/formLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textLicense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/license"
android:textSize="18sp"
android:textStyle="bold" />
<ViewSwitcher
android:id="@+id/licenseSwitcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3" >
<TextView
android:id="@+id/tvLicenseVariable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="LicenseViewClicked"
android:textSize="18sp" />
<com.timeondriver.petrolcontrol.MySpinner
android:id="@+id/spinnerLicense"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/license_prompt" />
</ViewSwitcher>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/date"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvDateVariable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:clickable="true"
android:onClick="DateViewClicked"
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/textPlace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/place"
android:textSize="18sp"
android:textStyle="bold" />
<ViewSwitcher
android:id="@+id/placeSwitcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3" >
<TextView
android:id="@+id/tvPlaceVariable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="PlaceViewClicked"
android:textSize="18sp" />
<EditText
android:id="@+id/editTextPlace"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:maxLines="3"
android:inputType="textMultiLine"
/>
</ViewSwitcher>
</TableRow>
</TableLayout>
場所データが短い場合のビューは次のようになります。
そして、これは、場所データの文字数が多すぎる場合(最初の行がいっぱい)のビューの外観です。
ライセンス、日付、時刻の行はサイズが制限されているため、問題ありません。場所データのある行は、文字数が多すぎる場合に列幅を変更する行です。列の幅を常に同じにするにはどうすればよいですか?
ありがとう!