Я использую настраиваемый диалог, который содержит текстовое поле, изображение и кнопку. Текст может содержать HTML. Иногда нижняя часть диалога отрывается снизу, когда текст достаточно длинный. Как я могу это предотвратить? Я хочу, чтобы Android определял размер диалогового окна, но, похоже, это не так. Должен ли я сам определять Диалог в этом случае?Android не размер Пользовательский диалог достаточно большой
Вот макет ...
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/alert_root_incorrect"
style="@style/AlertDialogTheme"
android:background="@drawable/rounded_alert"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rounded_alert"
>
<TableLayout
android:stretchColumns="0"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textStyle="bold"
android:text="Sorry, that's wrong!"
android:textColor="@color/gray_dark" />
<ImageView
android:id="@+id/check"
android:background="@drawable/xmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/alert_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:text="In fact, this is where the explanation will go. Something about how this passage related to the topic"
android:textColor="#000000" />
<Button
android:id="@+id/okay_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:background="@drawable/rounded_alert_button"
android:text="Okay"
android:textColor="@color/white"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
А вот код, я использую, чтобы загрузить его ...
if (null == layout) {
this.layout = inflater.inflate(R.layout.alert_incorrect, (ViewGroup) findViewById(R.id.alert_root_incorrect));
}
TextView message = (TextView) layout.findViewById(R.id.alert_text);
message.setText(Html.fromHtml(card.getConclusion()));
((Button) layout.findViewById(R.id.okay_button)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismissDialog(INCORRECT_DIALOG);
nextQuestion();
}
});
layout.requestLayout();
dialog = new Dialog(this, R.style.AlertDialogTheme);
dialog.setContentView(layout);
dialog.setCancelable(false);
return dialog;
А вот хруст, что я имею в виду ..
Спасибо,
John
Возможно, выбранный вами стиль имеет некоторые ограничения по размеру, что препятствует калибровке вашего диалога. Попробуйте без стиля и посмотрите, есть ли разница. 'LinearLayout' с' layout_weight' проще, чем 'TableLayout', и почему есть два вложенных' LinearLayout', которые вам только нужны. Устраните «лишние» взгляды, как это возможно, они могут помешать макету. У меня также была проблема с настройкой 'Button', когда также устанавливалась 'textSize'. Вы можете попробовать удалить прописку из 'Button'. Если ваш фон является 9-патчем, могут возникнуть проблемы с настройками полей. –