Is textAppearance and inbuilt theme attribute in Android? - android

I've been learning more concepts in Android and came across textAppearance.
android:textAppearance="?android:attr/textAppearanceLarge"
I did some research on this and came to the conclusion that this syntax refers to attributes in the Theme whereas # syntax refers to resources in the project / framework.
However, in my theme.xml file, I didn't define any item by the name of textAppearanceLarge. Therefore, I was wondering, is textAppearance and inbuilt item in the theme which Android provides?
Also, some background information on this topic would be really helpful.
Thank you!!

Yes textAppearance is inbuilt property of Android SDK.
TextAppearance allows you to define text-specific styling while leaving a View’s style available for other uses. Note, however, that if you define any text attributes directly on the View or in a style, those values would override the TextAppearance values.
TextAppearance supports a subset of styling attributes that TextView offers. For the full attribute list.
You can also read the following blog by Google developer to understand it in deep.
https://medium.com/androiddevelopers/whats-your-text-s-appearance-f3a1729192d
And also can refer to google documentation to understand the technical aspect of it.
https://developer.android.com/guide/topics/ui/look-and-feel/themes#textappearance

Use ctrl+ mouse_left_cllick to explore .......basically, it will direct you to the exact code.

Related

Using style instead of android:textAppearance

android:textAppearance allows you to apply an additional layer of styling for certain attributes on text views. I'm wondering whether the flexibility of this feature outweighs its complexity.
Is android:textAppearance required for any technical or visual reason?
What might be the consequences of relying solely on style throughout a project and omitting the use of android:textAppearance in layouts?
What if it were omitted from styles too?
Here's two guides that recommend the use of android:textAppearance:
Styling Views on Android (Without Going Crazy)
TextAppearance allows you to merge two styles for some of the most
commonly modified text attributes. Take a look at all your styles: how
many of them only modify how the text looks? In those cases, you could
instead just modify the TextAppearance.
Best practices for happy Android resources
To ensure consistent-looking TextViews, do not define any of the TextAppearance attributes in a normal style, but always set a TextAppearance from your library on that style’s android:textAppearance field.
Looking at TextView.java, there don't appear to be any attributes that are defined by android:textAppearance that are not able to be set on a TextView directly. So there doesn't appear to be any technical reason that one needs to use them over defining attributes in styles directly, at least in one's ability to configure how a TextView looks.
This means that you can avoid using it in your layouts as well as your styles without any adverse effects, provided that you override all the associated attributes. The base theme defines many different standard android:textAppearances for the various widgets, so you should check that all the widgets are properly overridden.
Based on my experience, android:textAppearance is most useful if you wish your app to appear to integrate into the rest of the device. So if you need big text, you can use android:textAppearance="?android:attr/textAppearanceLarge" and now your text is large! No need to know how many sp that means for the given device/screen size/etc..
However if your app is highly styled and you'd otherwise be overriding all the text sizes anyhow, the value-add of android:textAppearance diminishes. You can certainly use it as referenced in the posts above, but if that doesn't fit into your styling system, then feel free to omit it. It's just another tool to help you get a good-looking app across all devices.
I would also recommend making extra-sure that you try your app across a variety of devices if you choose not to use it, just to make sure that you didn't neglect to override a default android:textAppearance.

Are themes in android immutable?

I read in multiple places that themes are immutable. However, from this [method](https://developer.android.com/reference/android/content/res/Resources.Theme.html#applyStyle(int, boolean)) and this answer, I don't see how that is true. What do people mean when they say themes are immutable?
By immutable they mean that if you define a theme in a styles file, in XML, you cannot change its properties dynamically (programatically).
See the answer provided here: How to programmatically create an Android theme style?

Android custom gui-components?

Im searching for an android gui-library with more components i could use in my app.
Example:
A microcontroller sends the rpm of a motor (via bluetooth) to my smartphone.
And i want to use my smartphone in order to show the received rpm in progressbar-like element.
But the normal progressbar looks ugly, and i would have to progressbar.setClickable(false); .
As i said before
Im searching a library with more gui-elements(optional: i could modify, customize the outward appearance on my own)
Do anybody of you know about such a library ?
Thanks so far.
If you're just concerned about the external appearance of your GUI elements, I don't think there's any support for different UI elements than the ones provided. However, have you looked into a universal Theme and style for your application?
Here are some excerpts from that document:
A style is a collection of properties that specify the look and format
for a View or window. A style can specify properties such as height,
padding, font color, font size, background color, and much more. A
style is defined in an XML resource that is separate from the XML that
specifies the layout.
A theme is a style applied to an entire Activity or application,
rather than an individual View (as in the example above). When a style
is applied as a theme, every View in the Activity or application will
apply each style property that it supports. For example, you can apply
the same CodeFont style as a theme for an Activity and then all text
inside that Activity will have green monospace font.
Here are some resources which talk about themes:
Mobile Orchard Article
Android Engineer Article
Let me know if that's what you wanted. Themes give you almost infinite possibilities to modify outwards appearance.

Where can I find the values used in Android themes?

Does anyone know how I can find out what values are set in different Android themes? I know how to find the names of themes in the Graphical Layout view for a layout resource (Theme.Black, Theme.Light, Theme.Holo.Light, etc).
I want to find out the margins, color values, padding, and all that stuff for the different themes so I can make my app look consistent across devices whether they have a particular theme available or not.
You can get the information regarding the theme from the
#android:style/
So please Do it in your style.xml in value directory and you will get the default value of the style.
You can also add your custom style for any behaviour like theme or textAppearance or anything you want.
Also refer this.
Just refer it and you will get that values.
Hope it will help you.
Enjoy. :)
I think if you want to find the themes in certain device, you should get the source code of this device or decompile the framework-res.apk can also get styles.xml and themes.xml file. A lot of devices have changed the default themes, so if you want to make your app looks the same in different devices, the best way i think is to add android:theme in your AndroidManifest and refer to a self-build theme which does not inherit the system theme.

Android theme customization

I am working on theme-ing my android app. After I went through 'Styles and Themes' in Android SDK and this article, I am still left with one question.
Simply put, how can I use android:textSize to be 14 dip for one TextView, while 18 dip for another TextView, inside a Theme?
I know how to do this with styles. I can define two different styles and make the two different TextViews to use those styles.
What I find difficult is how to do this with Theme. A theme lets me define let's say android:textSize, but then it's applicable to all the TextView s in all the layouts of the Activity.
Any idea how to do that?
Thanks.
You can also do it with creating a style, for instance, "subtext", and apply the subtext style to multiple elements. Check out the links I posted in this question.
https://stackoverflow.com/questions/2973928/how-to-make-theme-of-application-configurable-by-user/3680841#3680841

Categories

Resources