Android:How to change the draghandle in a listview? - android

android:fastScrollEnabled="true"
which workes fine but the drag handle which appears is very ugly and i need to change it..
is their any direct method to change the image of the draghandle to something i want ??
If not what should be done?
Note:I am not asking for code,just guide me through it.Thank You.

It's just an image, so you can easily change it.
Add something like that to you application theme :
<item name="android:fastScrollThumbDrawable">#drawable/apptheme_fastscroll_thumb_holo</item>
Which refers to a drawable with 2 states :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#drawable/apptheme_fastscroll_thumb_pressed_holo" />
<item android:drawable="#drawable/apptheme_fastscroll_thumb_default_holo" />
</selector>
You can see an examle of what the drawable should be here : Android Holo Colors (enable Fast Scrool at the end of the list). It will look like that :

Related

How to change drawable image background while click

I am new to Android, I have an image, want to change background color programmatically while clicking that icon. How to do. Please, anyone help me.
I have icon like this, before click:
I want to change like this while click, after click:
You have to see:
how to apply click event listener to image in android
and inside of the click event listener:
backgroundImg.setBackgroundColor(Color.parseColor("#FFFFFF"));
or
backgroundImg.setBackgroundColor(Color.rgb(100, 100, 50));
What you need here is a selector.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/numpad_button_bg_selected" android:state_selected="true"></item>
<item android:drawable="#drawable/numpad_button_bg_pressed" android:state_pressed="true"></item>
<item android:drawable="#drawable/numpad_button_bg_normal"></item>
</selector>
And then you need to create the two images, because from what I see in the examples you also set the text color.
If you later want to change the overall color of the icon you can do that using AppCompatImageView and tinting.
Two Solution Available
Use Two Images and update on android:state_selected, android:state_pressed. Similar to dzsonni answer.
Use SVG Image.Update Programmatically.See Below link
Dynamically changing SVG Image colours on Android

android - listview with custom shape

I want to make a listview that has a custom shape background for every item in it.
This is exactly how I want it to look.
When a list item is selected, the color of it is a little bit darker, and it has an extra corner in the right.
What is the best way to achive something like this?
I've tried to make 2 images, and add both to my selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="#drawable/clicked" />
<item android:state_pressed="true" android:drawable="#drawable/clicked" />
<item android:drawable="#drawable/normal" />
</selector>
And set the listview listselector to it..but is not showing as I expected, and also i'm sure is not the best way to do it...
What do you think is the best way to achive this?

Android textColor selector

I am trying to set up a selector for TextView textColor using the following code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="?android:attr/textColorTertiary" />
<item android:color="?android:attr/textColorPrimary"/>
</selector>
However, the color always appears to be red instead of those theme colors. If I put hardcoded color, everything seems to work fine. (ex. <item android:state_enabled="false" android:color="#666666" /> ).
What is the problem and how to solve it? P.S. if anyone knows how to set theme's default disabled color for disabled item in the list, please share, that is what I am trying to achieve. Thanks.
As far as i can see you may have to use 3 states in a selector.
state enabled
state focused
state pressed
in exactly this order. This might help
You used selector for what reason?
If you want to make your text of text view always red then no need of selector. Just define color in color.XML or in string.XML using add color.
And if you want to chanhe it on selection or focus than use the states.
state enabled
state pressed
state focused
Than it will work as you need.

How to apply shadow color to Android EditText when focused?

I have an EditText control in my application and when it is focused (i.e. I'm ready to enter something) I want to apply shadow color to it. How can I do this?
Thanks,
#nagaraju.
You can use the Selector tag like Follows:
Create a New xml file and place it in your drawable folder and name it as shadow_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="#drawable/ask_footer"/>
<item android:state_focused="false" android:state_pressed="true" android:drawable="#drawable/askfooter_hover" />
<item android:drawable="#drawable/ask_footer" />
</selector>
And then go to that xml in which your EditText is declared:
And write one attribute in editText
android:background="#drawable/shadow_color"
and you are done.
Use a selector for your background drawable and create your own nine patches.
does shadow color mean you want a shadow theme background for your view??
then, assuming that you are using xml layout,the GU interface version shown on eclipse allows you to select a particular theme for your view,which i think is what you want.
if you want to put it manually,
you must mention it in the android manifest
eg.
<activity android:name=".activity_name here"android:theme="#android:style/Theme.Dialog">//there are a handful of effects provided by SDK
</activity>
i suggest the graphical user interface method,its easy and you can see the effect as you select the theme
You can also check whether your EditText isFoucsed or not. And if true so change its background image to shadow like image.

Default Eclipse Theme for Android Development Spinners?

The color of my Spinner widgets change from phone to phone based on there settings,I would like to keep them the same between all phones and I would like to have it be the default eclipse uses in its emulators the color is silverish. Can you please let me know how to apply this specific theme to my Spinner in xml. Thanks in advance.
download the images used in for the spinner from the android source code: spinner_press.9.png, spinner_select.9.png, spinner_normal.9.png then create selector using those.
this is the default selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="#drawable/spinner_press" />
<item android:state_pressed="false" android:state_focused="true"
android:drawable="#drawable/spinner_select" />
<item android:drawable="#drawable/spinner_normal" />
</selector>
You don't need to create a theme. Just apply a background of your choice to the spinner, as with any other View.
If you want to have different backgrounds you can use a (See here for more info)
For an example of an implementation, nothing better than the android source: https://android.googlesource.com/platform/frameworks/base/+/froyo-release/core/res/res/drawable/spinner_background.xml
You can get the actual 9-patch files from there also (and choose which version you would like to use).

Categories

Resources