background of custom icon in actionbar - android

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>

Related

Change the underline of android textfields in Titanium Alloy

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

SeekBar change gray color

I searched a lot but could not find.
I want the basic gray color of SeekBar change to white.
All the examples I've found it just change the color of progress.
Can anyone help me?
Try creating progress.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background"
android:drawable="#drawable/background_fill" />
<item android:id="#android:id/progress">
<clip android:drawable="#drawable/progress_fill" />
</item>
Then in your seekbar declaration in xml set:
android:progressDrawable="#drawable/progress"
You can refer below link for creating Android components such as editext or spinner or seekbar with your own colors for your Android application. It will generate all necessary nine patch assets plus associated XML drawables and styles which you can copy straight into your project.
For ex. for your case you can go to this link and download the zip file for your new seekbar with custom color.
http://android-holo-colors.com
Here you go:
<androidx.appcompat.widget.AppCompatSeekBar
android:progressBackgroundTint="#color/gray"
android:progressTint="#color/white"
Ok, So, there are two things
You want to change Seekbar style through out the app
You want to change Seekbar style for specific screen
If want to change through out the app. Add this in your style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="seekBarStyle">#style/AppSeekBar</item>
</style>
<style name"AppSeekBar" parent="Widget.AppCompat.SeekBar">
<item name="android:thumb">#drawable/ic_launcher</item>
<item name="android:background">#drawable/app_seekbar_background</item>
</style>
</resources>
And that's it, all SeekBar in the app will start using this style.
If you want to change for specific screen. Add this in your style.xml
<resources>
<!-- your rest of code -->
<style name"AppSeekBar" parent="Widget.AppCompat.SeekBar">
<item name="android:thumb">#drawable/ic_launcher</item>
<item name="android:background">#drawable/app_seekbar_background</item>
</style>
</resources>
And in the your_layout.xml file add this
<!-- your rest of code for layout -->
<SeekBar
android:layout_width="100dp"
android:layout_height="40dp"
style="#style/AppSeekBar"
<!-- your rest of code for seek bar-->
/>
This should reflect your style.
And if you want to change anything else for you can come to this style.xml file and change, no need to change each and places you are using SeekBar

How to remove dark line and gradient under action bar

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);

How to set custom color on selected/highlighted list-item in activatedBackgroundIndicator

Hello I am developing an app using ActionBarSherlock and Navigation Drawer. I have created an initial navigation drawer with actionBar Sherlock just like this:
Everything seems okay But I want to change default blue color of highlighted list-item with my custom color. I tried this link but it is not working. What I need to do to achieve custom highlight color?
Hello I have solved it for android OS version 11 and higher by applying style:
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:activatedBackgroundIndicator">#drawable/activated_background</item>
</style>
activated_background in the drawable folder:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="#color/uva_color" />
<item android:state_selected="true" android:drawable="#color/uva_color" />
<item android:state_pressed="true" android:drawable="#color/uva_color" />
<item android:drawable="#color/default_color" />
</selector>
Color values in the values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="uva_color">#c31756</color>
<color name="default_color">#111</color>
</resources>
And set choicemode in the listview:
android:choiceMode="singleChoice"
And at last, send getBaseContext() to arrayApdater/your customAdapter as parameter instead of getApplicationContext().
mMenuAdapter = new MenuListAdapter(this.getBaseContext(), title, icon);
Also this link would help you.
Comment below if you face problem anywhere. I am ready to answer anytime, I don't want to let anyone getting trouble with this like me. Cheers!

how to change the color of the tabs indicator text in android?

how to change the color of the text indicator of tab? i can change the icon using selector tag refered the example. but cant to the text color. how?
Here is a new answer I found from Fred Grott (http://knol.google.com/k/fred-grott/advance-tabs/) after a little web searching.
This lets you set a selector for text color so a different color can be used when tab is selected or not. Which can be very useful if you are using a different background color for the tab if its selected. Of course you can also just throw in a plain color and not a selector.
final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(this.getResources().getColorStateList(R.color.text_tab_indicator));
Where R.color.text_tab_indicator is a selector xml file located in your res/drawable folder.
In other words, the indicator text really is a TextView which is retrievable via the View object which can be accessed from the TabWidget object.
Take a look at Fred's examples for more info and context regarding the variable declarations as well as other tricks.
Style it
in your custom theme change
<item name="android:tabWidgetStyle">#android:style/Widget.TabWidget</item>
and
<style name="Widget.TabWidget">
<item name="android:textAppearance">#style/TextAppearance.Widget.TabWidget</item>
<item name="android:ellipsize">marquee</item>
<item name="android:singleLine">true</item>
</style>
<style name="TextAppearance.Widget.TabWidget">
<item name="android:textSize">14sp</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">#android:color/tab_indicator_text</item>
</style>
Danny C's answer is 100% correct.I just wanted to add something to it to make a complete answer with resource file.
The text_tab_indicator under res/color file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:textColor="#color/text_tab_selected"
android:state_selected="true" />
<item android:textColor="#color/text_tab_unselected"
android:state_selected="false" />
</selector>
And this text_tab_unselected & text_tab_selected will look like this under colors/values folder
<resources>
<color name="text_tab_selected">#ffffff</color>
<color name="text_tab_unselected">#95ab45</color>
After that finally add Dannyy's answer in tab class file
final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(this.getResources().getColorStateList(R.color.text_tab_indicator));
The change in color can also be stated without using java - which is probably better.
I made changes to the text_tab_indicator (notice textColor was changed to 'color'):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="#color/text_tab_selected" />
<item android:state_selected="false" android:color="#color/text_tab_unselected" />
</selector>
Set the style of the TabWidget to point to a specific style in your xml code:
<TabWidget
...
style="#style/TabText"
/>
Declare your text_tab_indicator located in /res/color as you desired color in the style
<style name="TabText">
<item name="android:textColor">#color/tab_text_color</item>
</style>
It worked like a charm (for me).
Cheers,
Randall

Categories

Resources