У меня есть следующий макет как пользовательский вид в AlertDialog.FrameLayout высота не соответствует родительскому
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:layout_gravity="center"
android:gravity="center"
android:padding="16dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:columnCount="3">
<TextView
android:id="@+id/code1"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:gravity="center"
android:text="\u2022"
android:textSize="@dimen/match_code_digit_size"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/code2"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="\u2022"
android:textSize="@dimen/match_code_digit_size"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/code3"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:gravity="center"
android:text="\u2022"
android:textSize="@dimen/match_code_digit_size"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k1"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="1"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k2"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="2"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k3"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="3"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k4"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="4"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k5"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="5"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k6"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="6"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k7"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="7"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k8"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="8"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k9"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:text="9"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/k0"
android:layout_width="@dimen/match_code_button_size"
android:layout_height="@dimen/match_code_button_size"
android:layout_column="1"
android:text="0"
android:textSize="@dimen/match_code_button_text"
tools:ignore="HardcodedText" />
</GridLayout>
<TextView
android:id="@+id/error"
style="@style/ErrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/match_error"
android:visibility="invisible" />
</LinearLayout>
<FrameLayout
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80ffffff"
android:visibility="visible">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
Извините за большой объем макета, поставьте его здесь «как есть».
Обратите внимание на нижний FrameLayout с идентификатором прогресс. Несмотря на то, что у него есть android: layout_height = "match_parent", на устройстве он выглядит как "wrap_content" - имеет высоту, соответствующую только внутреннему ProgressBar. Хотя в Android Studio дизайнеру показалось отлично, занимая весь вид.
Что случилось?
Вот как компоновка выглядит дизайнером
и на устройстве (пробовал как эмулятор и реальное устройство, тот же эффект)
вы можете разместить снимок и ожидаемых результатов, а также –
добавить тяжести вашего ребенка кадр макет –
@Alexey проверить мой ответ –