Overriding the dialog title layout in Android

I created a custom dialog theme in my Android application, and I planned to override the layout used for the dialog title. I saw that in the standard android Themethere is this attribute that looks like the one that needs to be changed.

<item name="dialogTitleDecorLayout">@layout/dialog_title</item>

But when I try to override it in my Theme

<style name="Theme.Dialog.MyDialog" parent="android:Theme.Dialog">
    <item name="android:windowBackground">@android:color/black</item>
    <item name="android:dialogTitleDecorLayout">@layout/my_dialog_title</item>
</style>

I see the following error:

A resource was not found that matches the specified name: attr "Android: dialogTitleDecorLayout

Why can't I change it and how do I know which attributes can be changed and which cannot?

+5
source share
1 answer

. , , - .

dialog_title.xml

<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/text" 
    android:text="@string/tell_a_friend"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="8dip"
    android:paddingTop="12dip"
    android:paddingBottom="12dip"
    style="@style/bigTextWhite" />

</LinearLayout>

// , onclick

public void onClickHelp(View v) {
    final Dialog duDialog = new Dialog(this);
    duDialog.setContentView(R.layout.data_usage);
    duDialog.getWindow().setBackgroundDrawableResource(R.color.title_text);

    duDialog.setTitle("Data Usage"); // I would like to set the color and add button here
    ListView data = (ListView) duDialog.findViewById(R.id.DataUsage);
    duCursor = Data.getAll(db);
    startManagingCursor(duCursor);
    duAdapter = new DataAdapter(duCursor);
    data.setAdapter(duAdapter);
    duDialog.show();

}
+1

All Articles