How to customize preferences screen title in Lollipop? - android

I make an Android application trying to support Android Lollipop and previous versions. So, I use Theme.AppCompat.Light for my app.
In Android 4.4, Action Bar title is white like I want and preferences screen titles are blacks.
In Android 5.0, Action Bar title is black by default and preferences screen titles are blacks. But, I want my Action Bar title be white on all versions of Android so I used the following customization in my theme for v21 :
<item name="android:textColorPrimary">#android:color/white</item>
With this customization, Action Bar title is white like i want but it seems that preferences screen title are also linked to android:textColorPrimary in Android 5.0 .
So, my question is the following. Is there a solution to create an Action Bar title with white title and in the same time have preferences screen title with other color like black?

Just make two styles.
One with:
<item name="android:textColorPrimary">#android:color/white</item>
One with:
<item name="android:textColorPrimary">#android:color/black</item>
Set your activities with action bars to the white one.
Set you preference activity to the black one.

Related

how to modify the action bar color scheme as in instagram

I want to change the action bar color and text color as in Instagram. Because when I make a gray color, the icon and the time are not clear.
try using this code,
<style name="statusBarStyle" parent="#android:style/Theme.DeviceDefault.Light">
<item name="android:statusBarColor">#color/status_bar_color</item>
<item name="android:windowLightStatusBar">false</item>
its not my code and i got this from here.
According to the guidelines, Starting with Android 5.0 all Notification icons must be entirely white.
The only way to have a colored icon is to lower your targetSdkVersion to values <21, but I think you would do better to follow the guidelines and use white icons only.
If you still however decide you want colored icons, you could use the DrawableCompat.setTint method from the new v4 support library.

Android action bar action color

I have an application with a lot of activities, that all use the same theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#aaa</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Activities all have action bar looking like by the lines of:
What I just can't figure out is, how to color action buttons (pencil on the right) to black.
Essentially I want to have white action bar (on screenshot is white just for action button to be visible) with black title, back arrow and action buttons, but I don't want to add Toolbar view to every activity I have.
So, is there a way to color action buttons black by XML?
Create vector icons for your menu items and set their color to black (in your case you won't need to set their color as they are black by default). To create vector asset go to File - New -Vector Asset.
You can also download an icon from the internet as svg file and import it through vector asset creating dialog.
The list of default icons is also available here.

transparent statusbar navigationdrawer after setstatusbarcolor

I'm try to developing an app with a navigation drawer from a template found on github.
In style.xml i have:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#0000ff</item>
and the status bar in navigation drawer is ok.
When i click the button it runs this command:
getWindow().setStatusBarColor(Color.GREEN);
Now the status bar color in navigation drawer is no more translucent
How restore status bar color to translucent?
The difference is that the xml defined colors colorPrimary and colorPrimaryDark are not really used to directly set the status bar color.
Actually the statusbar is completely transparent all the time and only the underlaying View is colored. Thats why it can have another color on the left than on the right side (have a look at your second screenshot). If you now call getWindow().setStatusBarColor(..) you indeed color the statusbar directly and over-draw the color of both Views. So it needs to stay transparent!
What you really want to do, is changing the color of the View underlaying the status bar, which is done with the ScrimInsetsFrameLayout class.
Have a look at this question and this class from the library you provided
There you should find all the necessary information to change only the color of the area you want to.
In case you really just want to reset the color:
getWindow().setStatusBarColor(Color.TRANSPARENT);

Logo in ActionBar instead of text

I want to put a picture on my action bar, instead of the text (No, I am not using action bar sherlock), and if possible for the action bar to be transparrent AND with detectable height (I have done transparent action bar before, but you can't get its height programatically this way).
It should be in styles somehow, not programatically. Right now I have this styles.xml and it does absolutely nothing...
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:icon">#drawable/img_ab_youlocal_logo</item>
</style>
P.S. YES, I have searched before asking, the other asnwers were not helpful.
If you are using an api < 21 you could do something similar this:
ActionBar actionbar = getActionBar();
actionbar.setDisplayShowCustomEnabled(true);
actionbar.setCustomView(R.layout.someLayoutfile);
You may have to this before the Parent View gets inflated / set via setContentView();
Also in api > 11 you have a logo attribute:
Using a logo instead of an icon
By default, the system uses your application icon in the action bar, as specified by the icon attribute in the
<application> or <activity>
element. However, if you also specify the logo attribute,
then the action bar uses the logo image instead of the icon.
A logo should usually be wider than the icon, but should not include unnecessary text.
You should generally use a logo only when it
represents your brand in a traditional format that users recognize. A
good example is the YouTube app's logo—the logo represents the
expected user brand, whereas the app's icon is a modified version that
conforms to the square requirement for the launcher icon.

action bar takes up entire screen

I am using Action Bar Sherlock for compatibility with earlier versions of Android. My objective is to not display the app title in the action bar, but to show a logo on the left and a couple of action buttons on the right. In my styles, I am using these options for the action bar:
<style name="MyActionBarStyle" parent="Sherlock.__Widget.ActionBar">
<item name="background">#drawable/toolbar</item>
<item name="displayOptions">showHome|useLogo</item>
<item name="android:background">#drawable/toolbar</item>
<item name="android:displayOptions">showHome|useLogo</item>
</style>
Everything works as hoped for on Android 2.3. On my Android 4.0.4 test phone, however, the action bar takes up the entire screen, with the app logo on the left, the action buttons on the right, but these are all centered vertically on the screen instead of residing at the top. The gradient for the toolbar, which is actually a very small pic dimensionally, occupies the entire screen (besides the status bar). The rest of the activity below the action bar is not visible.
If I remove showHome from the displayOptions above, the action bar no longer takes up the whole screen. But my logo is now gone. What do I need to do to get this working properly for Android 4?
Thanks in advance for any help.
I determined that this issue is not a problem with ActionBarSherlock, just with Android 4 in general. There seems to be a combination of options that causes this behavior to happen. I couldn't find a satisfactory solution with styles but was able to get the desired behavior in code.

Categories

Resources