編集ボックスの最大幅を設定したい。だから私はこの小さなレイアウトを作成しました:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxWidth="150dp" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" />
</LinearLayout>
とにかく、ボックスは150 dpを超える可能性があります。android:maxWidth="150dp"
でEditText
同じ結果が得られます。最大幅と最小幅の両方を同じサイズに設定すると解決するはずです(maxWidth は fill_parent では機能しません)。
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:maxWidth="50dp"
android:minWidth="50dp" />
しかし、そうではありません。
ここで私の問題の解決策を見つけました:
ViewGroup に最大幅を設定する
と、これはうまく機能します。しかし、私maxWidth
は理由のために属性がここにあると思います。どのように使用する必要がありますか?または、これに関するドキュメントはありますか?私はこの問題に何時間も費やしましたが、この単純な属性の使用方法をまだ理解していません。