How to align the Action bar Tab text in android - android

You can check out my output below.There you can see, In ANNOUNCEMENT,letter T is placed at bottom.It needs to be align like Gallery and placed in the center.
styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="GridLayout">
<item name="android:drawSelectorOnTop">true</item>
<item name="android:listSelector">#drawable/photogrid_list_selector</item>
</style>
<style name="CustomRatingBar" parent="#android:style/Widget.RatingBar">
<item name="android:progressDrawable">#drawable/custom_ratingbar</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
</style>
<style name="CustomTheme" parent="#android:style/Theme">
<item name="android:tabWidgetStyle">#style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText"
parent="#android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">12sp</item>
<!-- <item name="android:textStyle">bold</item> -->
</style>
</resources>
I doesn't know how to solve these issue.Anybody can help me if you know how to solve these.Thank you.

I just tried it almost two days.But I can't find a solution for
these.After that I think and solve these problem.
Actually I am using an emulator.So that these kind of problems
occurred for me.
Then I try to run these code in Real devices.It seems Action bar
Tab test Announcement align at the centre.Problem solved for me.

Related

Unable to customize ActionBar Tabs for API-23

I'm working on a application in which I am having Tab Bars. I am assigning a custom theme to my tabs using styles.xml present in values-v23 folder. But the thing is that I am not able to achieve my custom theme every time I'm launching the application. I can't understand where is the problem. I am sharing my style.xml file here to make you understand this better.
styles.xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<style name="AppThemeWhite" parent="AppBaseTheme">
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowBackground">#color/white</item>
<item name="android:textColor">#color/black</item>
<item name="android:editTextStyle">#style/BlackEditText</item>
<item name="android:actionBarTabTextStyle">#style/CustomActionBarTabs_TextColor</item>
<item name="android:actionBarTabStyle">#style/CustomActionBarTabs</item>
<item name="android:actionBarTabBarStyle">#style/CustomActionBarTabBar</item>
</style>
<!-- action bar tab styles -->
<style name="CustomActionBarTabs_TextColor" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#666666</item>
<item name="android:textSize">14sp</item>
<item name="android:typeface">sans</item>
</style>
Here I'm trying to change the text color of Tab titles by using the #style/CustomActionBarTabs_TextColor property but nothing is happening. Can someone please help to solve this one.
Any help would be appreciable.
Thanks.
you can apply following style to your tab layout
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">#color/indicatorcolor</item>
<item name="tabIndicatorHeight">4dp</item>
<item name="tabTextAppearance">#style/MyCustomTabTextAppearance</item>
<item name="tabSelectedTextColor">#color/seltextcolor</item>
</style>
<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#000000</item>
<item name="textAllCaps">true</item>
</style>

Android AppCompat, how to remove padding between action bar buttons?

In AppCompat, there is a 12dip padding on both sides of the action buttons. I want to make it 0dip. I have read a few posts and tried for hours, no success. Here is the content of my style.xml:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarStyle">#style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="Widget.AppCompat.Light.ActionBar">
<item name="actionButtonStyle">#style/CustomActionButtonStyle</item>
</style>
<style name="CustomActionButtonStyle" parent="Widget.AppCompat.Light.ActionButton">
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
</style>
In my case (Sony Xperia Z3 Tablet Compact android 5.1.1) was the only solution to add:
<item name="android:padding">0dp</item>
into CustomActionButtonStyle

Change text size of actionbar item in android

I want to change text size of action bar item.
here is my style.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionMenuTextAppearance">#style/menu_text</item>
<!-- Customize your theme here. -->
</style>
<style name="menu_text">
<item name="android:textSize">20sp</item>
</style>
this works on android 5 but on android 4 the text size is default and does not change.
in my Project folder res/styles AppTheme has a comment as below,
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
So you can do it with your app Theme. I have done it via below code,
<style name="Theme.YourTheme" parent="android:style/Theme">
<item name="android:actionBarStyle">#style/Theme.YourTheme.Styled.ActionBar</item>
</style>
<style name="Theme.YourTheme.Styled.ActionBar">
<item name="android:titleTextStyle">#style/Theme.Viadeo.Styled.YourTheme.TitleTextStyle</item>
</style>
<style name="Theme.YourTheme.Styled.ActionBar.TitleTextStyle" parent="#android:style/Widget.TextView">
<item name="android:textSize">12dp</item>
</style>
Hope this helps you.

how can we change the title text color of customactionbar in android?

here is my styles.xml file. Can you please tell me how can i change the title text color of the actionbar. By default text is been show as Black color.
styles.xml
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background" >#color/MyColor</item>
<item name="background">#color/MyColor</item>
</style>
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle" >#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
Ok I've found a better way. I'm now able to only change the color of the title, you can also tweak the subtitle.
Here is my styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle"parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</resources>

Experimenting with styles => No resource found that matches the given name: attr

I try to develop an app for API 8 but do not have any experience with styles.xml. For activities in the app I use Theme.Light. After playing with styles I got the error above. I've also checked other posts on this portal and I tried many suggestions but I could not get further. The styles.xml is below and hopefully someone will come with suggestions.
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="ContactLabelTextView">
<item name="layout_width">wrap_content</item>
<item name="layout_height">wrap_content</item>
<item name="layout_gravity">left|center_vertical</item>
<item name="layout_marginLeft">15dp</item>
<item name="layout_marginRight">5dp</item>
<item name="layout_marginTop">5dp</item>
<item name="clickable">false</item>
<item name="longClickable">false</item>
<item name="textSize">14sp</item>
<item name="textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">#android:color/black</item>
<item name="layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText" >
<item name="layout_width">match_parent</item>
<item name="layout_height">wrap_content</item>
<item name="layout_marginLeft">15dp</item>
</style>
After reading the post recommended by Alexander Zhak I have better understanding of styles. Therefore, I made some modifications to my styles.xml and it works. Those modifications are:
...
<style name="ContactLabelTextView" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:longClickable">false</item>
<item name="android:clickable">false</item>
</style>
<style name="ContactLabelTextView.Layout">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:layout_marginLeft">15dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">15dp</item>
</style>
...
You need to have a parent style to enable you to call the attributes of it.
sample:
<style name="ContactLabelTextView" parent="#android:style/TextAppearance.Medium">
The above code is used when you want your textView as a Medium size text, you can still change it what ever size you want for your TextView.

Categories

Resources