Creating TimePickerDialog with custom style in Android - android

I'd like to create a DialogFragment or a Dialog with a TimePicker inside, just like in the following image. The problem is that my application is using the Holo.Light theme and then from there, I'm customizing it, but I can't find anything related to TimePicker.
Is it possible to assign a custom style to a TimePicker? I haven't found anything in the official Android documentation.
The following image is what I got so far, but still the TimePicker isn't in the color I want (it's the same orange as in the separator of the title) even tho in the XML I have it as it follows:
<TimePicker
android:id="#+id/picker"
style="#style/Checkmark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip" />
Any ideas, please?
Thanks a lot in advance

I use HoloEverywhere https://github.com/Prototik/HoloEverywhere to have native Holo elements in android 2.2 and up. You can style the picker easily if you use this library since it's open source and you get full access to the code.
Probably you don't need the whole library, it might be good to get only the TimePicker elements (beware of the dependency hell)

Related

How to design the spinner with custom color and bottom border etc?

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

Picker showing as clock instead of spinner

I was creating a one of my activities separately from my main project because it was a big thing.
After making it work, I merged everything in my main app. Most of it was copy-paste and just change the paths and such.
Now, my problem is my time picker has a completely different look.
It should look like this [picker how it should be][1]
but it looks like this [how it's looking right now][2]
Like I said, I didn't change anything. Does anyone have any ideas?
Thanks
<TimePicker
android:layout_width="match_parent"
android:layout_height="match_parent"
android:timePickerMode="spinner">
</TimePicker>
Set timePickerMode to be Spinner

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.

Using NumberPicker in Android 3

I'm trying to use the NumberPicker widget in Android 3.1. I figure it is now a standard widget, part of a public API, and not an internal widget anymore.
However, it doesn't work. I can see a textEdit with "0" in it, but there are no buttons, I can't scroll it, and I can't enter a new number with keyboard, either.
Update:
Here's the xml I used for testing:
<NumberPicker
android:id="#+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
By saying doesn't work I mean this: it doesn't have arrows displayed (see the screenshot), and on emulator the keyboard doesn't show up. On a real device it does, but I can't type in the text, I can only erase it.
Any suggestions? I really hate to write my own widget when there is a standard one.
Try to set the values that are possible in the NumberPicker via
setMaxValue setMinValue or setDisplayedValues
maybe the NumberPicker is not working if it doesn't know which values to display.

Emulate android preference category look/feel

I like the title bar style from the Android preference category.
In my Activity (not a PreferenceActivity) How can I use the same style?
Since I just spent the last few hours trying to answer this old question, I'll do it here for anyone else.
It turns out the resource the preference category style is using is listSeparatorTextViewStyle.
You use it like this:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, World"
style="?android:attr/listSeparatorTextViewStyle"/>
Using style="?android:attr/preferenceCategoryStyle" didn't work.
The main layout is most likely a ScrollView with a LinearLayout. As for the individual layout, I believe (just guessing after looking at the documentation) that you can use the various attributes in android.R.attr - look here: http://developer.android.com/reference/android/R.attr.html. There are attributes like preferenceCategoryStyle, preferenceStyle, etc. You can apply any style to any of your views.

Categories

Resources