romannurik / AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
manifest . > |
. |
Make sure your app (or individual activity) uses the |
theme with the custom attribute defined. —> |
application android : theme = » @style/AppTheme » . > |
. |
application > |
manifest > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
public class MyActivity extends Activity < |
protected void onCreate ( Bundle savedInstanceState ) < |
super . onCreate(savedInstanceState); |
. |
// Pass in the theme attribute that’ll resolve to the |
// desired button style resource. The current theme |
// must have a value set for this attribute. |
Button myButton = new Button ( this , null , R . attr . myButtonStyle); |
myButton . setText( » Hello world » ); |
ViewGroup containerView = ( ViewGroup ) findViewById( R . id . container); |
containerView . addView(myButton); |
> |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
The convention is to put the And TextView initialization does: But it doesn’t recognize fontFamily attribute :S Is it a normal behaviour? This comment has been minimized.Copy link Quote reply jrub commented Jun 24, 2015Very useful indeed, thanks Roman. This should definitely be included into the official documentation for Themes & Styles (http://developer.android.com/guide/topics/ui/themes.html) This comment has been minimized.Copy link Quote reply ursusursus commented Feb 19, 2016For me this does not apply layout params like layout_width, layout_height when I have them in my style. Only default wrap_content LayoutParams gets created in both dimensions Источник |