I need to 'hide' the textSize parameter in BigButton style, inherited from Button. How to do so?
<style name="Button">
<item name="android:background">#color/button_background</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:padding">5dp</item>
<item name="android:textSize">#dimen/button_text_size</item>
</style>
<style name="BigButton" parent="#style/Button">
<item name="android:textSize"></item>
</style>
Try
<style name="BigButton" parent="#style/Button">
<item name="android:textSize">#null</item>
</style>
Related
I would like to change the textsize of popupmenu,so I try it in styles.xml and themes.xml,but the textsize seems to be override by android:textViewStyle.If I delete android:textViewStyle in my themes.xml,the textsize of popupmenu works.Is there something wrong in my code?
styles.xml
<style name="mytextviewstyle" parent="Widget.MaterialComponents.TextView">
<item name="android:gravity">center_vertical</item>
<item name="android:textAppearance">#dimen/body_text_appearance</item>
<item name="minHeight">#dimen/body_text_minHeight</item>
<item name="android:textSize">32sp</item>
</style>
<style name="mypopmenustyle" parent="Widget.MaterialComponents.PopupMenu.Overflow">
<item name="android:textSize">#16sp</item>
<item name="android:textColor">#color/white</item>
<item name="android:popupBackground">?attr/colorPrimary</item>
</style>
themes.xml
<item name="android:textViewStyle">#style/mytextviewstyle</item>
<item name="actionOverflowMenuStyle">#style/mypopmenustyle</item>
By the way,android:buttonStyle and buttonStyle don't work too.Still get the default button.
styles.xml
<style name="mybottonstyle" parent="Widget.MaterialComponents.Button">
<item name="android:gravity">center_vertical</item>
<item name="android:textAppearance">#dimen/body_text_appearance</item>
<item name="android:textSize">#dimen/body_textSize</item>
</style>
themes.xml
<item name="android:buttonStyle">#style/mybottonstyle</item>
<item name="buttonStyle">#style/mybottonstyle</item>
<style name="button" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="android:gravity">center</item>
<item name="android:layout_height">#dimen/button_height</item>
<item name="android:layout_width">wrap_content</item>
<item name="cornerRadius">#dimen/button_round_radius</item>
</style>
<style name="button.wide" parent="button">
<item name="android:fontFamily">#font/montserrat_regular</item>
<item name="android:layout_width">match_parent</item>
I do this in style file. but when I apply the style in layout. style="#style/button.wide"
the font doesn't work.
try using android:theme="#style/button.wide"
Change button style name and parent like, name="ButtonViewStyle"
and parent="android:Widget.Button"
<style name="ButtonViewStyle" parent="android:Widget.Button">
<item name="android:fontFamily">#font/montserrat_regular</item>
<item name="android:layout_width">match_parent</item>
</style>
Use <item name="android:buttonStyle">#style/ButtonViewStyle</item> line to your parent style
<style name="button" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="android:gravity">center</item>
<item name="android:layout_height">#dimen/button_height</item>
<item name="android:layout_width">wrap_content</item>
<item name="cornerRadius">#dimen/button_round_radius</item>
<item name="android:buttonStyle">#style/ButtonViewStyle</item>
</style>
Here is the default Option Menu style in android. Currently I tried.
My question is : I want to override the default to style of Option Menu. Like this!
which is only first character is cap and custom typeface.
Here is my implememtation.
//style.xml
<style name="HomeTheme" parent="AppTheme.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:fontFamily">#font/apercu</item>
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:actionMenuTextAppearance">#style/TextAppearance.Menu</item>
</style>
<style name="TextAppearance.Menu" parent="TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="android:fontFamily">#font/custom_type_face</item>
<item name="android:textSize">17sp</item>
<item name="android:textColor">#4d4d4d</item>
<item name="android:textAllCaps">false</item>
</style>
I accomplished it overriding AppTheme.Widget.ActionButton. Eg.
<style name="AppTheme.Widget.ActionButton" parent="#style/Widget.AppCompat.ActionButton">
<item name="textAllCaps">false</item>
</style>
and set it to my Activity's theme like
<item name="actionButtonStyle">#style/AppTheme.Widget.ActionButton</item>
What parent style should I use if I want to set global textViewStyle and maintain backward compatibility with AppCompat? I can't find something like Widget.AppCompat.TextView :
<style name="Base_AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textViewStyle">#style/GlobalTextViewStyle</item>
</style>
<style name="GlobalTextViewStyle" parent="?????">
<item name="android:textAppearance">#style/TextAppearance.AppCompat.Medium</item>
</style>
You just need to extend TextAppearance.AppCompat style overriding necessary values:
<style name="Base_AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textAppearance">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:textColorHint">?android:textColorHint</item>
<item name="android:textColorHighlight">?android:textColorHighlight</item>
<item name="android:textColorLink">?android:textColorLink</item>
<item name="android:textSize">#dimen/abc_text_size_body_1_material</item>
<item name="textColor">?textColorPrimary</item>
<item name="textColorHighlight">?textColorHighlight</item>
<item name="textColorHint">?textColorHint</item>
<item name="textColorLink">?textColorLink</item>
<item name="textSize">16sp</item>
<item name="textStyle">normal</item>
</style>
If you want to set this style for all your TextView's in your app, you can do something like this:
<resources>
<style name="YourTheme" parent="android:YourParentThTheme">
<item name="android:textViewStyle">#style/GlobalTextViewStyle </item>
</style>
<style name="GlobalTextViewStyle" parent="android:Widget.TextView">
<item name="android:textColor">#FF000</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
<style name="normal_text_white" parent="#android:style/TextAppearance.Medium">
<item name="android:textColor">#color/white_color</item>
<item name="android:textSize">#dimen/small_text_size</item>
<item name="android:textColorHint">#color/hint_color</item>
</style>
We can try this as well for AppCompat widget.
<style name="TitleStyle" parent="TextAppearance.AppCompat">
<item name="android:gravity">center_horizontal</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textSize">26sp</item>
</style>
I try to customize actionbar tabs. Look on the picture:
My code:
<style name="ActionBarTabBar" parent="#android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:showDividers">end</item>
<item name="android:divider">#drawable/actionbar_tab_divider</item>
<item name="android:dividerPadding">0dp</item>
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">50dp</item>
<item name="android:paddingRight">0dp</item>
</style>
<style name="ActionBarTab" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:showDividers">none</item>
<item name="android:measureWithLargestChild">true</item>
<item name="android:gravity">center</item>
</style>
<style name="CustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:listSelector">#style/ListView</item>
<item name="android:actionBarTabBarStyle">#style/ActionBarTab</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabBar</item>
</style>
I would like to align the text of tabs to center. When I try to set up showDividers to value middle, divider is not visible. It is visible with values beggining or end.
After more attempts, I've got desired result.
This is my code, that works properly.
<style name="ActionBarTabBar" parent="#android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">30dp</item>
<item name="android:paddingRight">30dp</item>
</style>
<style name="ActionBarTab" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:showDividers">middle</item>
<item name="android:divider">#drawable/actionbar_tab_divider</item>
<item name="android:dividerPadding">0dp</item>
<item name="android:measureWithLargestChild">true</item>
<item name="android:gravity">center</item>
</style>
<style name="CustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarTabBarStyle">#style/ActionBarTab</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabBar</item>
</style>
It was needed to specify the style for Widget.Holo.Light.ActionBar.TabView and for this item set up the divider.
Delete styles you don't need to override in order to style your tabs like you described:
<style name="ActionBarTabBar" parent="#android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:divider">#drawable/actionbar_tab_divider</item>
<item name="android:background">#drawable/actionbar_tab_bg</item>
</style>