2012-03-30 92 views
0

我有自定義的DialogPreference和自己定義的佈局。佈局文件如下:Android - 自定義DialogPreference中的奇怪佈局顯示

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 

android:paddingTop="5dp" 
android:paddingLeft="10dp" 
android:paddingRight="10dp" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/enter_password_label" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPassword"> 

    <requestFocus /> 
</EditText> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/confirm_password_label" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    /> 

<EditText 
    android:id="@+id/editText2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPassword" 
    /> 

在彈出的對話框都TextViews缺失:

enter image description here

什麼是不顯示TextViews的原因是什麼?

+0

你有沒有試圖改變文本的顏色 – Bhavin 2012-03-30 12:47:46

回答

0

此行爲的原因之一是由於製造商對主題的自定義。其他原因可能是所選文字外觀與背景顏色相同。爲了避免這種情況,你可能只是一個顏色設爲您的TextView,對於如:

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/enter_password_label" 
    android:textAppearance="?android:attr/textAppearanceLarge" 

    android:textColor="#000000" /> 

* 還要確保android:text確實有文字顯示在屏幕上