How to set default height to edittext view - android

I want to apply 60dp height by default to all my entire app EditText view. Where did i make mistake?
styles.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:editTextStyle">#style/custom_EditTextStyle</item>
</style>
<style name="custom_EditTextStyle" parent="#android:style/Widget.EditText">
<item name="android:background">#drawable/edittextbox</item>
<item name="android:height">60dp</item>
<item name="android:layout_marginTop">4dp</item>
<item name="android:layout_marginBottom">4dp</item>
<item name="android:singleLine">true</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
</style>
Thanks

Use
<item name="android:layout_height">60dp</item>
Not
<item name="android:height">60dp</item>

Related

How to change the dialog's button colors for a Material Date picker

I'm using Material components to create a DatePicker. From what I understand, colorPrimary is used to determine the color of the section at the top of the dialog, as well as the colors for the text on the buttons, specifically CANCEL and OK.
Going through the documentation, I can't seem to find a way to change just the color of the buttons at the bottom ? Is it possible to do that ?
current code:
<style name="ThemeOverlay.App.DatePicker" parent="#style/ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorOnPrimary">#android:color/white</item>
<item name="shapeAppearanceSmallComponent">#style/ShapeAppearance.App.SmallComponent</item>
<item name="shapeAppearanceMediumComponent">#style/ShapeAppearance.App.MediumComponent
</item>
<item name="materialCalendarHeaderTitle">#style/MyHeaderTitle</item>
<item name="colorOnPrimarySurface">#android:color/white</item>
</style>
<style name="MyHeaderTitle" parent="Widget.MaterialComponents.MaterialCalendar.HeaderTitle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ThemeMaterialCalendarTextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog.Flush">
<item name="android:textColor">#android:color/white</item>
<item name="iconTint">#android:color/white</item>
</style>
<style name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="android:textSize">24sp</item>
<item name="cornerSize">16dp</item>
</style>
<style name="ShapeAppearance.App.MediumComponent" parent="ShapeAppearance.MaterialComponents.MediumComponent">
<item name="android:textSize">30sp</item>
<item name="cornerSize">16dp</item>
</style>
You can use:
builder.setTheme(R.style.MaterialCalendarTheme)
and then define:
<style name="MaterialCalendarTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
<!-- Buttons -->
<item name="buttonBarPositiveButtonStyle">#style/TextButton</item>
<item name="buttonBarNegativeButtonStyle">#style/TextButton</item>
</style>
<style name="TextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">#color/...</item>
<item name="backgroundTint">#color/...</item>
</style>

Parent style for TextView style with AppCompat usage

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>

How can I use a style within another style for a button?

Does anyone have an idea how to add the style "MarginButton" to the style "bluebutton" or "OrangeButton"? The reason I'm doing this is to prevent double code, is this the correct way to do or are there better ways to solve this?
<style name="OrangeButton" parent="android:Widget.Button">
<item name="android:textColor">#000</item>
<item name="android:background">#drawable/roundedbutton_orange</item>
</style>
<style name="BlueButton" parent="android:Widget.Button">
<item name="android:textColor">#FFF</item>
<item name="android:background">#drawable/roundedbutton_blue</item>
</style>
<style name="MarginButton" parent="android:Widget.Button">
<item name="android:layout_marginTop">10dp</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:layout_marginLeft">3dp</item>
<item name="android:layout_marginRight">3dp</item>
</style>
Thnx,
Joris
Update
Set your orange button parent to #style/MarginButton. I've just tried this and it's working,
<style name="orangeButton" parent="#style/MarginButton">
<item name="android:textColor">#000</item>
<item name="android:background">#drawable/roundedbutton_orange</item>
</style>
<style name="MarginButton" parent="#android:style/Widget.Button">
<item name="android:layout_marginTop">10dp</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:layout_marginLeft">3dp</item>
<item name="android:layout_marginRight">3dp</item>
</style>
I think that you can obtain it by doing:
Buttons.xml ->
<style name="OrangeButton" parent="MarginButton">
<item name="android:textColor">#000</item>
<item name="android:background">#drawable/roundedbutton_orange</item>
</style>
<style name="BlueButton" parent="MarginButton">
<item name="android:textColor">#FFF</item>
<item name="android:background">#drawable/roundedbutton_blue</item>
</style>
MarginButton.xml ->
<style name="MarginButton" parent="android:Widget.Button">
<item name="android:layout_marginTop">10dp</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:layout_marginLeft">3dp</item>
<item name="android:layout_marginRight">3dp</item>
</style>
If you guys want to use borderless button like me or use two style. Try it.
View ->
<com.google.android.material.button.MaterialButton
android:id="#+id/btnCreateNewAcc"
android:text="#string/or_create_a_new_account"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4"
style="#style/textButtonStyle"
/>
Style ->
<style name="textButtonStyle" parent="android:Widget.Material.Button.Borderless">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetBottom">0dp</item>
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">0dp</item>
<item name="android:padding">0dp</item>
<item name="android:fontFamily">#font/inter</item>
<item name="android:textAllCaps">false</item>
<item name="android:textColor">#color/grey</item>
<item name="android:textFontWeight">400</item>
<item name="android:textSize">15sp</item>
<item name="android:background">#android:color/transparent</item>
</style>
You can do it changing the parent attribute. For example:
<style name="BlueButton" parent="MarginButton">
<item name="android:textColor">#FFF</item>
<item name="android:background">#drawable/roundedbutton_blue</item>
</style>

Alignment text of actionbar tab?

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>

How to hide the element style in child style element?

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>

Categories

Resources