How to make a preference more fancy? - android

I have been tired apply a style or a layout to a preference, but it didn't work well.
Could anyone help me with this?
I also find someone say it could be done in listview,But I wanna how to make those blank spaces between two block?
Please, help me with this , it has been puzzled me a long time.Thanks!

You can have a transparent divider between ListItems
android:dividerHeight="10 dip"

You can group your preferences by using PreferenceCategories and PreferenceScreens. If you want a preference to have an icon associated with it, you can use the android:icon attribute on the preference. Are there any specific characteristics of the iPhone settings that you're trying to replicate. You're not going to get your preferences to look exactly like the iPhones setting page, but you can certainly mimic certain characteristics.

Related

Horizontal Seletor

I need to create horizontal selector like in Uber android app (Please check screen shot). But that selector list must be dynamic means (Array[1,2,3,4...]). Please check screen shot:
I trid a lot but nothing worked with grate UI like this, I have trid also this link: check link. Its worked but bad UI because its uses paint to create things. Please help me to achieve same thing. I am trying it for payment selection option based on region. So its must be dynamic.
You can use android ui widget seekbar for this purpose and then customize it.
Also you can refer the following example
Seekbar

Setting/Changing, storing and reusing a custom gradient drawable programmatically

i am trying to let the user of my app customize its appearance. The user can set the gradient values for backgrounds, buttons and other controls/views. This is working quite well but i dont get an idea how to save and later retrieve the setting i.e. for a customized background setting.
Is there a way to save the gradient drawables setting in shared preferences or save these things as xml drawable and then let the app use that special customized drawable background ? Or are there better approches to reach that goal? Perhaps saving the settings in a database?
I thought of two drawable xml files for the apps backround (default_background.xml and custom_background.xml) and to choose between those programtically if a boolean pref is set to use custom colors is true...
But it doesnt seem to be possible to modify the custom file at runtime.
i've searched a lot but dont seem to find a proper answer... edit:(or cant find/imagine the right search terms)
perhaps someone here has an idea?
regards
Marco
edit: to perhaps better understand what i am trying to do
normally i define the background of the view/activity, lets say a linear_layout ( main.xml), by creating a drawable xml (bg.xml) file and then set the background property to bg.xml
now the application is started by the user. the user sets the background the way he likes the app to look to. I made a graphicSettings activity for this task. Now i am looking for a nice way to get the new customized background loaded in all (defined) activties. So every layout that formerly had the background property bg.xml now gets a new drawable.
here two pics ... (my repution is to low now :( )
edit: 01.27.15
I got the thing working with saving the values in sqlite db and retrieving the settings from the db. Now i have to load the values in each oncreate of the activities depending on the condition of my boolean pref useCustomGraficSettings.
Isn't there a more elegant way to solve the task?
i've searched a lot
No, you did not. https://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html

Android - Is it possible to change a property specifically for each ListPreference entry?

I have an ordinary Android ListPreference defined in my code -
<ListPreference
android:title="Font"
android:summary="Choose the font of the reader"
android:key="fontList"
android:entries="#array/fonts"
android:entryValues="#array/fontValues">
</ListPreference>
It gives a list of a couple of different font types that the user can pick from, nothing special. What I wondering is, is there a way to set each list item's font to the font that it displays? This would be a nice feature as it would allow the user to see what they have to pick from before having to test it out.
I can't see any obvious way of doing it, or at least a way that wouldn't destroy the nice default UI.
Any help would be appreciated.
The best way to do it would be to extend the ListPreference class and implement your own preference. From memory I think you need to override the onCreateDialogView, onBindDialogView, onSetInitialValue and onDialogClosed methods. Best place to look is at the List Preference page on developer.android.com
like he said for fonts u will need custom one. But what I found that there are alot of different default android:theme="#android:style/Theme....."
try the once that are available ... there are 9-10 of them.
maybe u will get somewhat closer to what u need that extending your own custom UI.

How to display default group icons in ExpandableListView?

I'm finding lots of discussion about how to replace the default group icons in an ExpandableListView, but I'm not coming up with anything on how to get the defaults to display in the first place.
The defaults (as shown here, if that's what they look like [new to Android, this is my first ExpandableListView]) will be fine with me, if I can get them to show.
I'm using the sample code from the article; I have no need for the embedded CheckBoxes at this time.
Any assistance is appreciated.
--EDIT--
Also, does anyone have any theories as to why the default icons show in the article (again, if that's what they look like--if someone could confirm that'd be great) but don't show for me?
If you are using custom layouts for your group rows the default icons are overridden by your layout. You'll need to add them to your layout in order for them to display.
you can changed default icon with your own icon as below.
android:groupIndicator="#drawable/image"

ListPreference - Custom items possible?

I'm trying to add an image / icon to certain entries of a ListPreference alongside the text.
I would like achieve this programmatically.
Here's an excerpt of the preferences.xml
<ListPreference
android:key="prefGameMode"
android:title="#string/pref_game_mode"
android:summary="#string/pref_game_mode_desc"
android:defaultValue="fourChallenge"
android:entries="#array/arrGameMode"
android:entryValues="#array/arrGameModeValues"
android:negativeButtonText="#string/cancel" />
...
The goal here is to illustrate that some of the options listed are unavailable/ locked in the current version of the app. However, the code-base is used as a library, so I would like the solution to work via code, rather than xml.
Any ideas how to do this? Thanks.
Preferences already gives you a way to indicate that an option is unavailable: just set enabled properly.

Categories

Resources