安卓:我如何设置一个布局TEXTSIZE?布局、如何设置、TEXTSIZE

由网友(终不敌时光)分享简介:我想在全球范围内设置TEXTSIZE和想不通或者找到一个方法来做到这一点。I am trying to set the textsize at a global level and cannot figure or find a way to do it.例如我有这样的事情:<?xml version="1.0"...

我想在全球范围内设置TEXTSIZE和想不通或者找到一个方法来做到这一点。

I am trying to set the textsize at a global level and cannot figure or find a way to do it.

例如我有这样的事情:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id = "@+id/Table"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:shrinkColumns="*"  
         android:stretchColumns="*">
</TableLayout>
</ScrollView>

该TableRows和TextViews本身是动态生成依赖于用户输入。

The TableRows and TextViews themselves are generated dynamically depending on user input.

问题是,我想设置在全球基础上的资源文件的基础TEXTSIZE而不必去触摸一堆code的。有没有办法告诉应用程序,哎应用程序,使用它作为你的基地TEXTSIZE所有textViews?

The problem is I would like to set the base textSize globally based on a resource file without having to go and touch a bunch of code. Is there a way to tell the app, "hey app, use this as your base textSize for all the textViews?"

或者另一种表述方式,在HTML我可以在身体,DIV,和表级别设置字体大小。有什么类似我可以在一个布局(的LinearLayout,TableLayout,滚动型等)的水平呢?

Or phrased another way, in HTML I can set the font size at the body, div, and table levels. Is there something analogous I can do at one the layout (LinearLayout, TableLayout, ScrollView, etc.) levels?

推荐答案

要为所有的TextView S上的全球性的造型,将的android: textViewStyle 属性,自定义主题和应用主题,应用程序或个人活动。

To set the global styling for all TextViews, set the android:textViewStyle attribute in a custom theme and apply the theme to your application or individual activities.

伪code:

<style name="MyTheme" parent="android:Theme">
  <item name="android:textViewStyle">@style/MyTextView</item>
</style>

<style name="MyTextView" parent="android:Widget.TextView">
  <item name="android:textSize">14sp</item>
</style>

...

<activity android:theme="@style/MyTheme">
  ...
阅读全文

相关推荐

最新文章