I don't know whether this question has been asked or not but I cannot find the answer so here I ask it.
In my android app, I want to create a spinner. But the spinner in my layout is terribly ugly.
This image is my layout. Note the yellow part marks the spinner layout in my layout.
And this one is the layout of an online spinner example
I want my spinner style look like in the second image. I tried to copy all the code in xml file. but there is no changes in the style of the spinner.
Anyone know how to have spinner style look the same as in the second image?
UPDATE: when I click on the spinner in the second layout, it shows me a list like this(note the points on the right side of the list)
while my spinner can only show a normal list (have no points on the right side)
I want my spinner can shows the same as that.
if you just want to have the spinner to be "holofied" you can do this:
<Spinner
android:id="#+id/spinnermap"
style="#style/MySpinnerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
values/styles.xml:
<style name="MySpinnerStyle" parent="android:Widget.Spinner">
</style>
set below attr for your spinner
android:spinnerMode="dropdown"
but it work for newer android version for older you can use support library or using IcsSpinner
Related
I want to customize the spinner in android. When i add the xml source for spinner it looks like this:
No border, only down arrow.
But i want to customize it for example like this:
Please don't make this for me. I just want to learn by my self and want to know what are the various ways to design and customize the spinner. I need to know about all the ways for example by using xml attributes of spinner, or separate xml style file, or xml shape file or with java etc. Further more, after knowing the ways i will design it by myself. A little example with each way will be appreciated. Thanks in advance!!!
Try adding style to the spinner
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#android:style/Widget.Material.Spinner.Underlined"
/>
I have a form in a DialogFragment that includes a spinner. I don't think I can port the spinner options out to a new activity (e.g. customisable ListView etc.) as it will close the DialogFragment, so I'm using the spinner embedded into the DialogFragment (screenshot 1). There is nothing unusual about how I'm populating the spinner with an ArrayList and adapter.
<Spinner
android:id="#+id/breedingcodes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dip" />
Functionally it works fine and the spinner options appear and are selectable, but looks terrible as it only uses half the screen (see screenshot 2), anchored to the position of the spinner in the DialogFragment. Is there anyway to force it to use the full screen, as in the 3rd screenshot with Breeding evidence title? I've tried fiddling with layout_height="match_parent" etc. - no joy.
App is developed for min SDK_10, compiled for SDK_23, build tools 23.0.3.
You can either create your own dialog and style it as you want, or just use
android:spinnerMode="dialog"
as attribute in spinner. See docs here
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
you could try the above in your program to get fullscreen spinner :)
I am using appcompat v21 in a project, but I do not like the new spinner it comes with by default. This new spinner comes only with a small downward-facing arrow that indicates it presence. I would prefer the old spinner used in 4.x versions of android which come with an EditText-like feature underlining the widget's content and an arrow in the bottom right corner.
How can I achieve this spinner style while still using appcompat v21?
The udesired spinner style:
photo of undesired spinner:
photo of desired spinner:
You can simply set the Style of the Spinner to Widget.Holo.Light.Spinner
Example
<Spinner
android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#android:style/Widget.Holo.Light.Spinner" />
This will give you the old Spinner-Style back though there are two drawbacks:
This solution only works with API-Level 14 and up (no that big of a deal)
The appearance of the DropDown Popup-Window is managed by the "framework" - this means on pre Lollipop devices the Popup-Window will appear below the Spinner. Starting with Lollipop it'll be above the Spinner (afaik there's no way to change this). With regard to this see the following comparison (on the left pre Lollipop)
If you wish to customize the rows of the DropDown you can do so by calling setDropDownViewResource(int) on the adapter of the Spinner with the reference to your own layout.
<Spinner
android:id="#+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:overlapAnchor="false"
style="#style/Platform.Widget.AppCompat.Spinner"/>
I have an android app that has been working fine pre-Android 5.0. With the update, I noticed that checkboxes and radiobuttons placed on white backgrounds are not visible if they are not selected. For example, this is what a checkbox looks selected and unselected in jellybean:
As you can see, there is a light gray square when the checkbox is not selected. However, after updating to lollipop, this is what it looks like:
So, as you can see, there is no gray square or anything that suggests there is a checkbox here. The same problem happens with radiobuttons. I really don't want to go trough the pain of creating new drawables just for this simple ting. I have seen that checkboxes within the accessibility menu of android 5 have a nice square, but haven't figured out how to make mine look the same:
I tried creating a new android project and just adding some checkboxes and radio buttons with a white background, but they are still invisible when unchecked. I'm using xamarin studio and c#, if that makes any difference. Anyway, I'll understand any java code you post.
This is what my checkbox code looks like:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/chkSeleccionar"
android:layout_gravity="right"
android:gravity="center_vertical"
android:clickable="false"
android:focusable="false"
android:scaleX="1.5"
android:scaleY="1.3"
android:layout_weight="50"
/>
I couldn't get the theme working, but what did work for me was the following:
android:button="#drawable/abc_btn_check_material"
android:buttonTint="#color/red"
Put this into your CheckBox XML layout.
Just change the
android:buttonTint="YOUR COLOR"
It works.
Make sure you are using a Material theme for Android 5.0 devices - this will ensure you're styling remains consistent with other components. Look for an android:theme element in your AndroidManifest.xml file (either on your application or on an individual activity), then look up what style is set there and check the parent attribute for the style.
Add this attribute
android:buttonTint="#EEEEEE"
The button has is set in the activity's XML layout with:
<Button
android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/dummy_button" />
The part to pay attention to is style="?buttonBarButtonStyle". The definition for the queried style is defined in styles.xml as:
<style name="ButtonBarButton" />
The style doesn't actually set any values for the button and so I can't understand why I would change anything about the button and the way it displays.
When the button is set to use the empty style, it looks like this:
But when the line style="?buttonBarButtonStyle" is removed, it looks like a standard button like this:
At first I thought that assigning the empty style would replace the default style settings for a button, but trying this in my own app doesn't change the appearance of a button at all (as I would have expected an empty style to do).
Can anybody work out exactly why this empty style is changing the look? To replicate this yourself you can create a new app using the "Fullscreen Activity".
Your ButtonBarButton and buttonBarButtonStyle has no relation to each other. You apply buttonBarButtonStyle style which is a theme attribute and defines some style for a bar button. If you can to apply your custom empty style to a button use:
style="#style/ButtonBarButton"
I'm not sure what it is that is surprising to you. The usual look of buttons is the one in the second image, so when the style is applied, that inside rectangle is removed which is a custom look. If you have seen buttons without any custom styling you would have seen that they look like the one in the second image.