Custom spinner like android 4.0 - android

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

Related

Hint on spinner on android spinner with Kotlin

I'm trying to put a spinner on a layout for android app. Unlike other components, the spinner does not come with an option to give a hint. How can I do it?
This is my spinner:
<Spinner
android:id="#+id/spinner_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/gender"
android:background="#android:color/white" />
When it's not selected I want to show a text like "Gender". When we select it i want that we can't select the option gender and that we only select Male or Female.
The options inside spinner are in an xml called where I keep the arrays.
Thanks.
Unfortunately Spinner don't have this feature built-in. Please check this post
This feature can be easily implemented through the library with so much customization:
https://github.com/Mobile-Innowise-Group/HintedSpinner
Usage of the library and with a lot of customized params:
<com.innowisegroup.hintedspinner.HintedSpinner
android:id="#+id/hintedSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
app:hintTextSize="24sp"
app:hintTextColor="#color/red"
app:hint="Custom hint"
app:withDivider="true"
app:dividerColor="#color/dark_green"
app:arrowDrawable="#drawable/example_arrow_4"
app:arrowTint="#color/colorAccent"
app:popupBackground="#color/light_blue"
app:items="#array/text" />

Correct way of applying material design to checkbox on old devices

I have a checkbox that on Lollipop devices looks like material design guildelines suggest. However, when I open this check box on old android devices, it looks like a default checkbox there.
What is the right way of making sure ALL standard components look on old (14+) android versions same as in Lollipop?
Use support libraries and android.support.v7.widget.AppCompatCheckBox
<android.support.v7.widget.AppCompatCheckBox
android:id="#+id/checkbox_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
/>

Android Appcompat v21 - use old spinner style

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"/>

Different layout in android

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

How can I get the native Android Editbox

I have created an Editbox in XML using this code:
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:inputType="textEmailAddress" >
</EditText>
The textbox renders like this:
How can I get the native android EditText with the orange borders when focused, white background etc. ?
I tried adding
android:background="#android:color/white"
but that only changes the background to white.
The style you are seeing is "native" for the Honeycomb (3.0) Android version, specifically, the new Holo-dark theme. The orange-borders-and-white-background look was last used in 2.3.* and has since been left behind.
Agree with the answer of neutrino: The style you are seeing is "native" for the Honeycomb (3.0) Android version, specifically, the new Holo-dark theme.
But still if you wants the EditText that you want then you need to set the style/theme inside the AndroidManifest.xml file:
<activity android:theme="#android:style/Theme.Light">
when we add view's from layout, it renders from framework, then add the properties we provided . so in your code, EditText is native EditText, which varies from device to device . so if you want look and feel over a particular device make your own style for that and use it .
Had the same problem...
Try using:
EditText usr=(EditText)findViewById(R.id.editText1);
usr.setBackgroundResource(17301528);
If you really want to older versions of the EditText iamges (from sdk/android-8/platforms/data/res folder), place thema in the drawable folder, create a StateListDrawable out of it, and set the background of the EditText as that Drawable. But why bother ? Let app users enjoy the default look and feel of their device.

Categories

Resources