My problem is straight-forward.
I have a default spinner in android API 19.
But i want to customize it to make it have a border and also a triangular shape at the end pointing at the bottom. (Like the spinner with old versions of android).
I have this spinner: http://androidopentutorials.com/wp/wp-content/uploads/2014/03/android-4-spinner.jpg?f9f065
But I want the spinner to be like this: http://lh4.ggpht.com/-DwIrYX29Rzg/TsPtjLkIkLI/AAAAAAAAAjs/m3GvtKmRDGo/firstLayout_thumb.png?imgmax=800
How can i customize the spinner?
I have searched for tutorials online but i got only those custom spinner with image and text together.
Have a look at this tutorial: http://www.mokasocial.com/2011/03/easily-create-a-default-custom-styled-spinner-android/
Basically, what you need is a 9-patch that you will use as a background of your Spinner.
The steps are fairly simple:
Get your 9-patches ready.
Create a <selector> that represents the stats of your Spinner by using these 9-patches.
Set the <selector> as the background for your Spinner.
The caveat to my approach is that you will have to set the background for every Spinner you use. If you want to 'do it once, use it everywhere', follow the tutorial approach where the author uses a custom theme.
Related
I am working with custom spinner. I am struggle on this.
How can I get the spinner like this ?
Note : I have the red color image.
From API 21, you can use widget tinting feature, most widgets (spinner included) will follow your colorAccent.
For lower APIs, you can apply custom drawable. Check android-holor-colors for a quick generation of your widget drawable. In your case, check 'Spinner' or 'Colored Spinner'.
Try Custom adapters.
You can design how a row of your spinner looks like.
The link bellow will help you.
http://androidexample.com/Custom_Spinner_With_Image_And_Text_-_Android_Example/index.php?view=article_discription&aid=84&aaid=107
I created with Android Studio 1.0 a new project and added a spinner. But the result doesn't look very understandable. It's not clear enough that the spinner is a clickable object. It shows only the top element and a small arrow down. My default Spinner
I've implemented the spinner the way the developer-page from android describes.
How can I change it to something, that looks more like this.
I've tried things like setting the background color, but in the result the little arrow disappears.
How is it possible, that my default layout looks so different from the declared one by developer.android.com?
In any case you can create your own custom spinner or set some selector to it. For example: http://androidexample.com/Custom_Spinner_With_Image_And_Text_-_Android_Example/index.php?view=article_discription&aid=84&aaid=107
In this picture you can see (barely lol) that the spinner icons that rest on the bottom and bottom right are very hard to see due to the black background that I am using. What would I need to do to make that greyish looking color to white or any color for that matter?
Try this tutorial:
Android Custom Spinners
A similar process is used for working with custom buttons and other elements.
Updated as the link is broken. Try this stackoverflow answer
Spinner Background Design
I've created my own custom preference objects that extend Preference. I've only created them because there are no Preferences for these custom data types.
Everything is working, but my custom preferences don't have the same appearance because they are missing the horizontal divider that the system preference objects have. I've looked for the code that is creating the horizontal divider, but I can't find where it is done.
The built in divider isn't just a thin bar. There is a bit of a gradient to it. I'm thinking that this may be in a layout file, but I can't find the layouts for the system preferences.
Anybody got an idea how this is implemented?
Very old post, but to those who stumble upon this. Wasn't sure if the OP was asking how to change the divider or where the divider images come from. So I'll address both.
How
Preferences uses a ListView for populating all the individual preferences. That means you can change the divider by using the .setDivider() method from ListView. A PreferenceActivity will already have the getListView() method for you. However for PreferenceFragments just use the android.R.id.list ID to find it.
If you don't want to change the divider through code, you can always use a theme by overriding the listDivider attribute. Eg:
<item name="android:listDivider">#drawable/custom_divider</item>
Note, that will change the divider for EVERY ListView in your app.
Where
The listDivider drawable used depends on what Android theme is activated. You'll find all these images in the installed Android SDK at this location:
[Android SDK]/platforms/[API]/data/res/drawable-[DPI]/
Just do a search for `*divider_horizontal*`, and you'll turn up quite a few. They are nine-patched and not all of them are solid colors.
In my app I'm using a spinners to let the user select an item from a list. Everything works fine but I'm not really happy with the look of the spinner. As you can see in the image below it has the same design as a normal button.
What I want is a spinner which looks more like a normal text field. So I browsed a little bit through the drawable folder of the Android sources and found out that the spinner background should normally look quite different. I append an image of a spinner with the background image as I found it in the drawable folder. Although the spinner in the image is focused, I think you can see the difference between both spinners.
Now I'm wondering why the my spinner (first one) doesn't have the same design as the second one as II didn't changed any attributes which are related to the design of it. Where does this button like design come from?
The first spinner screen depicts the default spinner.
So the answer is that you've expected the wrong behavior. You can however create your own spinner look.
Looks to me that the second spinner was there in the earliest versions of the android sdk and just remains there as is.