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"/>
Related
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 a Spinner in my app. I used the basic spinner and this is my code:`
android:layout_width="match_parent"
android:layout_height="match_parent"
style="#style/SpinnerSpinnerTheme"
android:spinnerMode="dropdown"
android:layout_gravity="center_vertical"
android:id="#+id/hj_order_date_spinner"
/>`
and this is how i instantiated in my activity
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.hj_spinner_items,android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dateSpinner.setPrompt("Sort By");
dateSpinner.setAdapter(adapter);
This works fine in android 4.4.4 but on Nexus 5(using Lollipop) the drop down list/Popup changes it's position and hides the "Sort By" bar or the original spinner.
Can anyone provide any insight as to what might be the issue?
You can specify whether the spinner drop-down should overlap the anchor by using the android:overlapAnchor attribute. When using the Material spinner style, this attribute defaults to true.
<Spinner
...
android:overlapAnchor="false" />
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"
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
I try to make custom spinner looks like in android 4.0, but I dont know how to replase sprinner dropdown selection list. Any help is welcome.
I get resource files from android 4.0 sdk, but dopdown selection list does not change.
<Spinner
android:id="#+id/update_frequency_spinner"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:spinnerMode="dropdown"
android:background="#drawable/spinner_background_holo_light"
android:dropDownSelector="#drawable/list_selector_holo_light"
android:popupBackground="#drawable/menu_dropdown_panel_holo_light">
</Spinner>
This How to customize style from spinner dropdown CHOICES? may answer your question.
You could also look into using HoloEverywhere if you want a holo-themed app for pre holo devices https://github.com/ChristopheVersieux/HoloEverywhere