I have read the article How to customize list preference radio button
I use the following xml lyaout to customize my Dialog, I think that most of default UI of android Dialog is very good, I hope to inherit att, and only change font size.
I have find the default att of CheckedTextView is android:checkMark="?android:attr/listChoiceIndicatorSingle".
Now I hope to find the default android att of both <TextView android:id="@+id/dialog_title" ...>
and <ListView android:id="@android:id/list"..>,
could you tell me? Thanks!
BTW, the default style of dialog title of listPreference isn't style="?android:attr/windowTitleStyle"
BTW, I can't the same Title effect if I use style="?android:attr/dialogTitle"
a.PNG is the effect of using style="?android:attr/dialogTitle"
b.PNG is the effect of default dialog title of ListPreference
You can try it, use the sample How to customize list preference radio button
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="@drawable/btn_radio_holo_light"
android:gravity="center_vertical"
android:minHeight="@dimen/list_item_minheight"
android:paddingLeft="@dimen/list_item_paddingLeft"
android:paddingRight="@dimen/list_item_paddingLeft" />
<?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" >
<TextView
android:id="@+id/dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textColor="@color/title_color"
android:textSize="22sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/divider_color" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
To Vikram:
- android:textColor="@android:color/holo_blue_light" don't work under API 9, how can I set color value for android:textColor? BTW, android:textColor="#ff4d4dff" is wrong.
- android:listSelector="?android:attr/selectableItemBackground" don't work under API 9, how can I setfor API 9? At present, I use android:background="@android:color/white". BTW, the default background of API 9 is black.
- I have to add android:background="@android:color/white" for LinearLayout android:id="@+id/title_template", because the default background of API 9 is black.
Modified For API 9
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:orientation="vertical">
<LinearLayout android:id="@+id/topPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical|start"
android:minHeight="64dip"
android:layout_marginStart="16dip"
android:background="@android:color/white"
android:layout_marginEnd="16dip">
<TextView android:id="@+id/dialog_title"
android:textSize="22sp"
android:textColor="@android:color/black"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="2dip"
android:visibility="visible"
android:background="@android:color/black" />
<!-- If the client uses a customTitle, it will be added here. -->
</LinearLayout>
<LinearLayout android:id="@+id/contentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:minHeight="64dp">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
/>
</LinearLayout>
</LinearLayout>
<TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle" ... />
and for ListView : `<ListView android:id="@android:id/list" style="?attr/preferenceListStyle" .../>. Try and let me know whether it works. – Manish Mulimani