2017-01-06 5 views
0

リストが表示されたときにメッセージとタイトルを表示できるようにカスタムタイトルビューを作成する必要がありました。リストはダイアログのコンテンツ領域に表示されるためです。したがって、ダイアログはメッセージとリストの両方を表示することはできません。AlertDialogsのタイトルテキストをカスタマイズするためのデフォルトのタイトルテキスト表示スタイルを使用

マイカスタムビューはのLinearLayoutです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:padding="24dp" 
       android:paddingBottom="20dp" 
       style="@style/Base.Theme.AppCompat.Dialog.Alert" 
    > 

    <TextView 
     android:id="@+id/alert_dialog_custom_title_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     /> 

    <TextView 
     android:id="@+id/alert_dialog_custom_message_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="14sp"/> 
</LinearLayout> 

パディング値とテキストサイズがしかし、この外観は異なっているmaterial design guidelines

enter image description here

与えられた情報に基づいて与えられましたデフォルトのものです。

screenshots

私の質問

  • どのように私は、デフォルトの1と同じスタイルを持っているのTextViewを作成することができますか?

はたぶん私のTextView

編集にスタイルを設定するなどの方法があります:私はちょうどデフォルトAlertDialogと同じその視認を作るスタイル属性を設定します。

私のTextViewには次のようにすでにある:あなたのスタイルで

<TextView 
     android:id="@+id/alert_dialog_custom_title_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="messsage" 
     style="?android:attr/titleTextStyle" 
     /> 
+0

androidは、テキスト用のサイズを提供しています。 –

答えて

0

あなたはあなたのために、この

<style name="TextAppearance.AlertDialogPro" parent="android:TextAppearance" /> 

を使用することができます:私はちょうどこのようにすることをやりたい

<TextView 
     android:id="@+id/alert_dialog_custom_title_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="messsage" 
     android:layout_marginBottom="20dp" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     /> 

スタイルを追加することができるテキストビュー

<TextView 
     android:id="@+id/alert_dialog_custom_title_textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="messsage" 
     style="@style/TextAppearance.AlertDialogPro" 
     android:layout_marginBottom="20dp" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     /> 
+0

私の遅い返事には申し訳ありません。しかし、これは答えではありません。あなたが私の質問を見ることができるので、私はすでにtextviewの属性を設定することができます。これは私が望むものではありません。私は、視覚をデフォルトのAlertDialogと同じにするスタイル属性を設定したいだけです。 – ziLk

+0

アンドロイド:textAppearanceMediumもデフォルトのAlertDialogの正しい値ではない "18sp"です – ziLk

+0

自分のコードを更新しました。 –

関連する問題