android - View added to Layout inherits parent's style -
I am reusing a custom I use Default device style for Delete button button button Simple for these layouts (/res/values/styles.xml) Style is: Here's how I am creating and adding buttons: I also tried to apply the style to the button on creation, such as: but it does not help at all. Is there something I'm missing, or what's going on with it? This is not the style that I am going with eventually, it was just for testing and then I went on the issue. InputDialog which is in the DialogFragment extension is adding more EditInputDialog to the Delete button. It's all right, but now I'm playing with genres and found this small problem:
& lt; Style name = "myBackgroundStyle" parent = "@Android: Style / Theme.Dialog" & gt; & Lt; Item name = "Android: Background" & gt; # FF0000 & lt; / Item & gt; & Lt; / Style & gt;
button btnDelete = new button (getActivity ()); BtnDelete.setText ("Delete"); Relative layout RL = (relative layout) view.findViewById (R.id.inputLayout); Layout: LP = New Layout Prurm (Layout Perm. WRAP_CONTENT, Layout Para. WRAP_CONTENT); Lp.addRule (relative layout. RIGHT_OF, R.id.btnSave); Lp.addRule (Relative Layout. ALIGN_BASELINE, RID.BTN Save); BtnDelete.setLayoutParams (LP); Rl.addView (btnDelete);
new button (getActivity), empty, android. Attr.buttonStyle); .buttonStyle I have not tried one
You will need to provide the reference of the dialog instead of the context of the button so that it can be retrieved The correct subject (using dialog base class is a contextthemeWrapper , it wraps the activity reference while providing its own theme).
Changing getActivity) was passed to the button constructor with getDialog (). GetContext () should fix the problem Note that LayoutInflater is initiated with the onCreateView () callback with the correct reference, and you You can get it by calling inflater.getContext. () .
Comments
Post a Comment