私はTextViewでListViewを以下にしたいので、このカスタムレイアウトを持っています。それはの下にあり、リスト項目をクリックして対話が閉じないようにしたいのです。 (AlertDialogはそのリストビュー上で、独自のメッセージビューを表示します。)AlertDialogに追加されたカスタムレイアウト内のTextViewのtextAppearanceをDialog'sに一致させるにはどうしたらいいですか?
<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="14dp"
android:paddingEnd="10dp"
>
<ListView
android:id="@+id/optionList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:choiceMode="singleChoice"
android:divider="@null"
/>
<TextView
android:id="@+id/messageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp"
/>
</LinearLayout>
を私は、ダイアログのTextViewに、私のレイアウトの両方にテキストを入れて、偽のセットアップを行いました。結果のスクリーンショット。
私もalert_dialog.xml
はそれを持っているので、私のレイアウトで、@のID/messageViewでstyle="?android:attr/textAppearanceMedium"
を入れてみました。ダイアログのメッセージよりもテキストが大きくなりました。また、色が一致しない、あまりにも明るい(アクティビティのデフォルトの色のように)。
ビルダーのLayoutInflaterを使用しようとしましたが、これはドキュメントに記載されているとおりです。
val infl = builder.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val view = infl.inflate(R.layout.dialog_report_profile, null)
builder.setView(view)
私が言ったように、それは中程度のように思えます。理由は分かりません。テキストサイズとダイアログビューを一致させるその他のアドバイスはありますか? – user3175580
代わりに '@android:style/TextAppearance.DeviceDefault.DialogWin dowTitle'を使うことができます。 – shiftpsh