0

私は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に、私のレイアウトの両方にテキストを入れて、偽のセットアップを行いました。結果のスクリーンショット。

Heading

私も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) 

答えて

0

あなたはいつもTextViewstyle="?android:attr/textAppearanceMedium"android:color="#000"の両方を置くことができます。

それとも、あなたは自分のres /のstyles.xmlにこれを追加することができます。

<style name="DialogMessageText" parent="@android:style/TextAppearance.Medium"> 
    <item name="android:textColor">@android:color/black</item> 
</style> 

をし、あなたのTextViewに次の行を置く:style="@style/DialogMessageText"

+0

私が言ったように、それは中程度のように思えます。理由は分かりません。テキストサイズとダイアログビューを一致させるその他のアドバイスはありますか? – user3175580

+0

代わりに '@android:style/TextAppearance.DeviceDefault.DialogWin dowTitle'を使うことができます。 – shiftpsh

0

は、これらのリンクをお試しください:link 1 & link 2

これらは助けるかもしれません

関連する問題