Set custom font to Dialog Preferences - android

I created custom dialog to get input from users extending DialogPreferences class for setting. i need to change font used in dialog and external font using typeface. i set the font to massage using following code. but i couldn't set it for title because i couldn't find the title view also buttons( id of title and buttons).
Text View message = (Text View)view.findViewById(android.R.id.message);
message.setTypeface(font);
how can i do this?
thank you.

Related

How to Create a custom tab layout that mimics the default tab text

I need to create a custom tab layout, but I want the text to mimic the style used in the normal TabLayout.TabView.
To do that, I've set my text appearance to TextAppearance.Design.Tab.
If you take a look at TabLayout itself, you can see that's what TabView's text uses:
mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab);
...
TextViewCompat.setTextAppearance(mTextView, mTabTextAppearance);
However, when my tabs display, I can clearly see the text is not the same. It's very similar, but the default tab looks to be more bold.
What am I doing incorrectly?
The answer was to set the text appearance programmatically. Setting android:textAppearance on the TextView in the XML file doesn't seem to do anything. Setting the text appearance programmatically (like TabLayout.TabView) works.

How to know the font family of default style in notification?

I create my custom view for notification and use TextView instead of Action.
The problem is: I want the TextView to be displayed with default style (as in default notification), but the TextView is displayed in different style.
So I need to know exactly the font-size, font-family of the default style. If I know these values, I can set them as the style of TextView.
Can anybody help me?
Use android:paddingLeft="8dp" for the text SHARE and decrease textSize by 1sp or 2sp.
Basically, the font size used are as follows :
micro : 12sp
small : 14sp
medium : 18sp
large : 22sp

How to get the name of font by a TextView or EditText in android?

I want to get the name of font set up on a textview, I am able to get Typeface but cant get the exact font name. I've setup new font on textview as following...
textView.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Segoe UI Light"));
Can I get back Segoe UI Light?

Matching default color in custom preference

I have a custom preference that is basically a slider.
The custom XML for the preference slider can be used to set text color, but I need to MATCH the text color to the default that the device uses. The Title color seems fine, just uses default (same as another CheckBoxPreference title, or so it looks). The Summary color is also using the default color (same as Title), but I want this to match the default color of the Summary text of a CheckBoxPreference, which is defined right above it in XML.
Can I get the color of the Summary text from the CheckBoxPreference and just change the Summary text color of the custom preference to match the CheckBoxPreference Summary color, or is there a global (R.attr.xxxxxxxx whatever) that I can use that exists on all devices?
For example, I have a checkbox preference that does not specify title or summary colors - thus, it uses the default color scheme (but this color scheme looks like the title matches, but the summary text in the custom preference (from xml) is the same as the title color, but not the default summary color as default preferences)).
My custom slider (which has title and summary fields) needs to match the default OS colors for those two fields to the device default color scheme for those entries (title & summary).
How do I get the default device color that is set for a checkboxpreference when no color is specified?
How do I assign that color to my custom preference, which has it's own xml file that defines the custom preference view.
Hope this makes perfect sense, if not I'll elaborate a bit more.
preference definition for the custom preference (which is further defined in it's xml):
<com.xxx.sbp.SeekBarPref
android:id="#+id/xmlpreference_seekbar"
android:key="preference_seekbar"
android:title="Seek Bar Pref"
android:summary="Choose seconds"
android:defaultValue="20"
android:max="300"
sbp:min="10"
sbp:interval="10"
sbp:intervaldivide="10"
sbp:unitsLeft=""
sbp:unitsRight="s" />
I found these: android:textAppearance="?android:attr/textAppearanceLarge" and android:textAppearance="?android:attr/textAppearanceSmall" seem to do the trick.
A complicated solution is given in Android preferences summary default color?
I agree with the respondents to above that neither of the textAppearance settings will guarantee a color match.
The default color for preference summary text appears to be #DACC45. The way I did this was to take a screen snapshot and query the colored pixels with an image editor.
I've had the same problem and I've solved it with these lines in onCreateView method of seekBarPreference.java
TextView summaryText = new TextView(getContext());
summaryText.setText(getSummary());
summaryText.setTextAppearance(getContext(), android.R.style.TextAppearance_Small);

change dialog typeface to use external fonts

I need to change the dialog's typeface to use an external font that supports some unicode characters. Unfortunately, there is no AlertDialog.setTypeFace() method available...
Any ideas?
You should be able to create your own dialog with a custom view, say with a TextView that has the custom font in it.

Categories

Resources