У меня есть xml-макет, который работает на некоторых устройствах, но вылетает, когда надувается на других (xml-код показан только частично):
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintLayout_record_audio"
android:minWidth="@android:dimen/dialog_min_width_major"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
Раздувание макета отлично работает на некоторых устройствах, но вызывает InflateException
на других.
Я нашел виновника в своем xml-файле:
<!-- Causes InflateException on some devices:
android:minWidth="@android:dimen/dialog_min_width_major" -->
К сожалению, после удаления строки, вызывающей InflateException
, android:layout_height="wrap_content"
больше не работает.
layout_height
всегда отображается так, как если бы он был установлен на "match_parent"
. Есть идеи о том, что происходит и как это решить?
ДОБАВЛЕНО ДЛЯ ЯСНОСТИ
Вот как я называю Диалог:
fun showRecordAudioDialog(view: View, categoryId: String, detailId: String) {
val dialog = RecordAudioDialogFragment.newInstance(categoryId, detailId)
dialog.show(this@DetailsActivity.supportFragmentManager, "RecordAudioDialog")
}
В моем RecordAudioDialogFragment:
// Use the Builder class for convenient dialog construction
val builder = AlertDialog.Builder(activity, style.CustomTheme_Dialog)
val inflater = activity.layoutInflater
val rootView = inflater.inflate(layout.dialog_record_audio, null)