Layout Inspector - How to find text element's current font - android

After taking a snapshot of the layout and inspecting it with Layout Inspector, how do I find what font is used for the selected TextView or AppCompatTextView? Text and Theme property groups have no mentions of fontFamily property. However, I see the TextView has a custom font on it.
I'm running Android Studio 3.2.1

The only thing i can see about font is the typeface (text -> getTypeFaceStyle(), "bold", "normal" ...)
If the font is defined in styles, you can see the textviews style (theme) in LayoutInspector at the bottom

Related

Text styles used in Settings app for titles and subtitles

which text styles are used for the titles and subtitles in the Settings app? I tried using the following, but none of these produced the same result.
Title text
android:textAppearance="?android:titleTextAppearance"
android:textAppearance="?attr/title"
Subtitle text
android:textAppearance="?android:subtitleTextAppearance"
android:textAppearance="?attr/subtitle"
Text style is often not enough to achieve a particular style, you often need to set color too. In this case, I suspect they use Google Material Components styles. It's hard to judge the appropriate font size here given your font scale, but here's what I think they use:
Title
android:textAppearance="?textAppearanceBody1"
Subtitle
android:textAppearance="?textAppearanceBody2"
android:textColor="#color/material_on_background_emphasis_medium"
They also use a special font.

Android Studio "paint brush" icon in front of certain attributes

In the attributes pane, I occasionally see two attributes with the same name, where one attribute has what looks like a "paint brush" icon in front of it (for example, in the screenshot below, the text attribute). I've searched but can't find what this means or what the difference is between the attributes.
If you enter some text in the text field with the "paint brush" icon
then this attribute will be added to the xml:
tools:text="989"
this attribute, from the tools namespace (xmlns:tools="http://schemas.android.com/tools"),
is set for design time, a value you can see in the preview of the layout and it is not compiled.
If you enter some text in the text field without the "paint brush" icon then this attribute will be added to the xml:
android:text="888"
this is the attribute that will be compiled in the apk of your app and you will see when you run the app.

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.

TextView with custom font isn't centered vertically

I need to use a custom font (VAG Rounded, probably not relevant) but the font changes how my TextViews react.
In the image below, you can see the two textviews with a black background. The left one use the custom font, the right one the default system font (Roboto ?). Both of them have the same xml properties and size, but the padding is not the same and more important, the left one isn't centered vartically !
How can I make the TextView draw its content well centered ?
You can try to remove your customs font padding from your text style (styles.xml):
<item name="android:includeFontPadding">false</item>
If this still doesn't work, i would set a general padding in your styles xml.
I think that you have to set android:layout_height="match_parent" and then also android:gravity="center"
then if you post also your source code we can give you more information
I could not change the font, and I wasn't going to edit each character using an editor (I don't even know what I should have done to fix it).
Si I ended up measure the difference with the default font and I added 0.15f * fontSize in the padding top...

Android - styling custom Dialog

I have a custom dialog in an xml layout.
How can I style it so it:
doesn't have a title
in other cases when I do want a title, change the color of the title divider line
has completely square edges instead of those slightly rounded corners that Android dialogs have by default
android customising style link
There is style folder inside res folder. Please take look over it. it basically xml file which has resource tags where you can configure you custom styling. And refer the same styling from style attribute in xml.

Categories

Resources