2017-01-06 15 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> 

패딩 값과 텍스트 크기는 그러나 enter image description here

material design guidelines

주어진 정보에 따라 주어진,이 모양이 다르다 디폴트의 ​​값

screenshots

내 질문 :

    나는 기본 하나에 같은 스타일이있는 텍스트 뷰를 만들 수있는 방법
  • ?

아마 내 텍스트 뷰

편집에 스타일을 설정하는 등의 방법이있다 : 난 그냥 기본에 AlertDialog와 같은 자사의 시각 성을 만드는 스타일 속성을 설정할.

내 텍스트 뷰는 다음과 같이 이미 :

<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

android : textAppearanceMedium도 기본 AlertDialog의 값이 아닌 "18sp"입니다. – ziLk

+0

내 코드를 업데이트 했으므로 사용해 볼 수 있습니다. –