I have created a custom theme for dialogs in my android app, and I was planning to override the layout used for the dialog title. I saw that in the standard android Theme
there is this attribute that looks like the one to modify.
<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:
No resource found that matches the given name: attr 'android:dialogTitleDecorLayout'
Why I not able to change it and how can I know which attributes can be changed and which not?
It is not possible to override that item like this. You have to customize the dialog with required layout and then in the layout you have to apply the theme here for what ever your requirement.
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>
//this is the method where your dialog appears in onclick button event
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With