How to make Preference widget appear below title in Android? - android

I'm new to Android development and wonder if there is an easy way to have a Preference (androidx.preference.Preference) with the widget appearing below the title? I am aware that layoutResource can be set to a custom layout, but I actually only need to change the widget (so I can set widgetLayoutResource instead of layoutResource) and I want it to appear below the title. If I change the whole layout to a custom one, I have to make it look like the other Preference layouts manually, which seems like an overkill given that I only want to change the title position.

Related

Preference grouping without title

In the Android Settings section of the Material Design Guidelines, it mentions that section titles are optional for preference groupings, and in the image, the last section shows a grouping without a title but with a divider between groupings.
However, I am not able to implement this properly. If I use a PreferenceCategory with no title set, there is a blank space where the title would be. I can't just throw in a View in a PreferenceScreen to a draw a divider, and the promising looking PreferenceGroup is abstract or otherwise not able to be used.
So, how can I achieve this?
You can get the divider using app:allowDividerAbove="true" or app:allowDividerBelow="true" as per your need. Using PreferenceCategory tag is not needed as these attributes can be set in any level of preference hierarchy.

How to change the default spinner-layout?

I created with Android Studio 1.0 a new project and added a spinner. But the result doesn't look very understandable. It's not clear enough that the spinner is a clickable object. It shows only the top element and a small arrow down. My default Spinner
I've implemented the spinner the way the developer-page from android describes.
How can I change it to something, that looks more like this.
I've tried things like setting the background color, but in the result the little arrow disappears.
How is it possible, that my default layout looks so different from the declared one by developer.android.com?
In any case you can create your own custom spinner or set some selector to it. For example: http://androidexample.com/Custom_Spinner_With_Image_And_Text_-_Android_Example/index.php?view=article_discription&aid=84&aaid=107

Custom font in TextView

I have been making a Digital Clock App Widget, and I have a font I'd like to use, however I can not make a custom View. Tried it, seems like it is not intended to work in a widget(I found out later that I can't use custom views in widgets). And I would really like to have that font, any suggestions?

Where is the default Preference layout?

I would like to make a custom layout for a Preference with just a very small change from the default layout.
Where can I get the default layout for a Preference so I can simply make my minor change without having to create a nearly identical layout from scratch?
I know, it's an old question but in case anyone is looking for this still (like me):
Here is the default preference layout for androidx
This folder contains all the widget xml (like SeekBar) as well.

Create custom button based on Android style

I need to create a custom button control that will inherit from the same Android style as all other buttons in my application. However, I want to be able to add several lines of text where some characters of the text will be in different colors. Is there anyway to achieve this, I can't seem to see a way?
Currently I have created a view that looks like a button by drawing the background, this is ok but I want the background etc to change with the application style.
You should make your button descend from the generic theme for Widget.Button. This way you can ensure that all the default settings will come through for you.

Categories

Resources