How do i remove this line under the action bar?
(source: android.com)
I would like it to be a solid color like the way google+ or the below app is:
i have tried
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
But that doesnt seem to remove it. All i want to do is just use a solid color, no tiled image, no gradient.
they this code it is override Background of actiobar
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(getResources().getDrawable(
R.drawable.actionbar));
drawable/actionbar.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#06B697" />
</shape>
You can change the style the ActionBar using the styles.xml file in res/values
In the theme you are yusing for your app write
<item name="android:actionBarStyle>#style/actionBarStyle</item>
and add the style actionBarStyle
<style name="actionBarStyle"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background>Color or drawable you want as background</item>
</style>
Here is a nice tutorial about this
alternativly, you can style the actionbar programmatically from an activity:
getActonBar.setBackgroundDrawable(drawable you want as background);
Related
I am trying to change the underline color of Android textfields in Titanium Alloy using a custom theme, but for some reason it doesn't pick up my new colors(s).
I have created a theme under project/app/platform/android/res/values/awesome_theme.xml with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="awesome" parent="#style/Theme.AppCompat">
<item name="colorControlNormal">#ff0000</item>
<item name="colorControlActivated">#00ff00</item>
<item name="colorControlHighlight">#0000ff</item>
</style>
</resources>
And I have changed my tiapp.xml file to use the new theme:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<application android:theme="#style/awesome"/>
</android>
I have cleaned the project, but the text field is still showing up with the default blue underline when I rebuild the project.
What am I doing wrong here?
You have to use a different background image, go to your XML "awesome_theme.xml" and add the custom EditText style
<style name="EditTextCustomHolo" parent="android:Widget.EditText">
<item name="android:background">#drawable/apptheme_edit_text_holo_light</item>
<item name="android:textColor">#ffffff</item>
</style>
insted of using image drawble file--> apptheme_edit_text_holo_light in that EditText style you can use a drawable resource file which has a stroke , go with that one or this stroke one ,
<?xml version="1.0" encoding="utf-8"?>
<item>
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#color/white"/>
</shape>
</item>
then Just do this in your EditText:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/EditTextCustomHolo"/>
or
you can change Underline of EditText color specifying it in awesome_theme.xml. add the following tag under your style Theme.AppCompat.
<item name="android:textColorSecondary">#color/primary_text_color</item>
Note : android:textColorSecondary is used to determine the color of the back arrow and DrawerLayout hamburger icon in the ActionBar, too soo careful
I am developing an application and i set "android:textIsSelectable" for the TextViews.
But my material theme is not matching with the TextSelection appBar. Is there a way by which i can change the color of that appBar ??
Attached the Image Below Check it :-
Assuming you use the appcompat-v7 library add these to your theme:ยจ
<!-- this makes sure the action mode is painted over not above the action bar -->
<item name="windowActionModeOverlay">true</item>
<item name="actionModeBackground">#drawable/myapp_action_mode_background</item>
Now I wasn't able to style the insides of the action mode (text color, icon colors) so hopefully you won't need to.
Note: If you don't use the support library prepend those style item names with android:. These will work above API 11+.
EDIT
For an action mode background with a stroke create a new drawable and update the reference. The drawable could look like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-2dp" android:left="-2dp" android:right="-2dp">
<shape android:shape="rectangle">
<solid android:color="#color/primary_dark"/>
<stroke android:color="#color/accent" android:width="2dp"/>
</shape>
</item>
</layer-list>
In your resources styles.xml: "android:textColorHighlight"
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorHighlight">#color/yellow</item>
</style>
</resources>
You can put in whatever color you choose and whatever parent theme you are using.
i am setting custom icon but its showing some white background rather then my transparent icon
here is may code that i have tried , i am using app compact actionbar
this.getSupportActionBar().setCustomView(R.layout.home_actionbar);
this.getSupportActionBar().setIcon(R.drawable.icon);
this.getSupportActionBar().setDisplayShowCustomEnabled(true);
this.getSupportActionBar().setDisplayUseLogoEnabled(true);
and here is the screen shot
You have to create a file in drawable folder. Name it "action_bar_icon_clicked", then paste this code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#color/dark_grey" />
<item android:drawable="#color/dark_grey"/>
</selector>
Then, in the style file, at the app theme add this line:
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/action_bar_icon_clicked</item>
</style>
I am trying to style the actionbar of my app (I use Actionbar Sherlock) by changing its background.
I set up a theme for my Application containing the following line to style the Actionbar:
<item name="android:actionBarStyle">#style/ActionBar</item>
I then created a style called Actionbar:
<style name="ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="titleTextStyle">#style/TitleText</item>
<item name="android:titleTextStyle">#style/TitleText</item>
<item name="background">#drawable/actionbar_background</item>
<item name="android:background">#drawable/actionbar_background</item>
</style>
Finally I have an image file named actionbar_background.9.png (3x5px) in my drawable folder, which looks like this:
All of this style my actionbar just fine but there's a red to purple gradient at the bottom and I don't understand what creates that. Below are screenshots of the rendered ActionBar (the first one using the image above, the second one when I replaced the red pixels with green ones):
I tried replacing the red with green in the image file and the gradient changes accordingly (from green to purple) but I still don't get why there is a gradient.
Anyone can point me into the right direction?
I ended up using the following layerlist as the drawable for the actionbar background:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/brand_orange" />
<item android:drawable="#color/brand_purple" android:bottom="2dp" />
</layer-list>
All suggestions welcome for another approach using 9-patch.
I've inherited the Holo Light Theme and customized the background of the ActionBar with the following:
Content of styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
</style>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
</resources>
Content of actionbar_background.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#raw/actionbar_background"
android:tileMode="repeat" />
Instead of being repeated, the image is stretched, any idea of why android:tileMode="repeat" is not applied?
Thanks in advance
Drawable d=getResources().getDrawable(R.drawable.background_image_name);
getActionBar().setBackgroundDrawable(d);
The above code sets the background image for the action bar.
Hope it helps.
Ok, thanks to Romain Guy on #android-dev IRC channel, it's a known bug on honeycomb / Android 3.0 which will be fixed on the next release. Since then, the only solution is do it from code, and it works :-)
final ActionBar actionBar = getActionBar();
BitmapDrawable background = new BitmapDrawable (BitmapFactory.decodeResource(getResources(), R.raw.actionbar_background));
background.setTileModeX(android.graphics.Shader.TileMode.REPEAT);
actionBar.setBackgroundDrawable(background);
You can easily do this thing. If you would like to change Action Bar background image then you place this code to your res/styles.xml file.
<style name="Theme.MyAppTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/Theme.MyAppTheme.ActionBar</item>
</style>
<style name="Theme.MyAppTheme.ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/top_black_bg</item>
</style>
For this you have to select an image from "drawable" folder . Here I select an image "tp_black_bg.png"
After that don't forget to declare this theme to your AndroidManifest.xml file
<application
.
.
.
android:theme="#style/Theme.MyAppTheme" >.............</application>
Now you can reopen any XML layout file , you can easily see the effect. In the same way you can also able to change the background color of ActionBar.
Thanks.
mActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));
Use getSupportActionBar() from android.support.v7 for backward compatability.