2
I持って私のダイアログの以下のレイアウト:アンドロイド - layout_weightと複数行のボタンの高さが設定
は私がいないことを最初のボタンをしたい:下のボタンに問題があります
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="@string/practice_question" />
<TextView
android:id="@+id/dialog_select_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="@color/primary_text"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
<ListView
android:id="@+id/dialog_select_answers"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/dialog_select_board_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/practice_look_board" />
<Button
android:id="@+id/dialog_select_answer_button"
style="?attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/practice_answer" />
</LinearLayout>
</LinearLayout>
切り取られた。私はandroid:layout_height="wrap_content"
を設定しましたが、それは助けになりません。
P.S.ボタンのテキストを「ボード上を見る」から「ボードを見る」に変更すると、すべて正常に動作します。しかし、私は2番目のボタンをオプションにしたいので、最初のボタンは親の幅全体と一致するかもしれません。
あなたの解決策を試してみてください、あなたのコードの一部を変更しました。私の質問の編集を見てください。問題は解決されるので、私はあなたの答えを受け入れるでしょう。 –
@ArtemMostyaev android:layout_below = "@ + id/dialog_select_answers"をリストビューで削除し、線形レイアウトでandroid:layout_below = "@ + id/dialog_select_answers"を追加します。私は私の最後にこれを実装しようとしています。あなたも試してみて、それが動作しているかどうかを教えてください。 –
はい、うまくいきます!私はあなたの答えに編集として正しいレイアウトを投稿します。 –