问题
According to Android Developer Design Style for Typography, there are 4 TextAppearance
s (Micro, Small, Medium, Large).
But there is no predefined style for Micro:
?android:attr/textAppearanceMicro
android:style/TextAppearance.Micro
None of them can be found in sources of Android. What am I missing?
回答1:
Good question! After researching a little bit, I didn't find any results for "TextAppearance.Micro".
On the other hand, I found the official Android source for style resource related to TextAppearance
s.
<style name="TextAppearance.Small">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?textColorSecondary</item>
</style>
<style name="TextAppearance.Medium">
<item name="android:textSize">18sp</item>
</style>
<style name="TextAppearance.Large">
<item name="android:textSize">22sp</item>
</style>
As you can see, all of them only affect the text size (except TextAppearance.Small
, which also affect the text color). So, I can safely say that the site displays the text sizes as a guideline only. On the other hand, you can always add a custom style to support TextAppearance.Micro
! Just insert this inside styles.xml
.
<style name="TextAppearance.Micro" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">12sp</item>
</style>
and use it like:
<TextView
...
android:textAppearance="@style/TextAppearance.Micro" />
On a bit related note, when I searched "textAppearanceMicro", I found 3 projects on GitHub. All of them adding some custom attributes, which one of them is textAppearanceMicro
. Also, all of them are using ActionBarSherlock
. I don't know whether there is a connection between textAppearanceMicro
and ActionBarSherlock
, but I didn't find that attribute was used anywhere in the code.
回答2:
If you happen to use the Google AppCompat
Library, you can use the following:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
来源:https://stackoverflow.com/questions/24301329/missing-textappearances-micro-style