写个样式 放在style.xml里面,字体大小和颜色 都是放在values目录下面配置成常量。

解决方案 »

  1.   

    你的界面使用的样式中加入一个全局字体样式。 这样所有未设置字体大小的,全部会使用这个字体大小了<style name="AppTheme" parent="AppBaseTheme">
      <item name="android:textSize">28sp</item>
    </style>
      

  2.   

    兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个style属性。
    <style name="TextStyle">
            <item name="android:textSize">30sp</item>
        </style>
    用的时候
     <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="北京天安门"
            style="@style/TextStyle"/>
        
        <EditText 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           style="@style/TextStyle" />
      

  3.   

    兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个style属性。
    <style name="TextStyle">
            <item name="android:textSize">30sp</item>
        </style>
    用的时候
     <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="北京天安门"
            style="@style/TextStyle"/>
        
        <EditText 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           style="@style/TextStyle" />
      

  4.   

    兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个style属性。
    <style name="TextStyle">
            <item name="android:textSize">30sp</item>
        </style>
    用的时候
     <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="北京天安门"
            style="@style/TextStyle"/>
        
        <EditText 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           style="@style/TextStyle" />
      

  5.   

    你要在配置文件里使用这个主题才有效果<application
            android:name=".app.MyApp"
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".ui.activity.LoginActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
      

  6.   


    你看我的配置文件,已用了一个主题,怎么能让这两个主题都同时使用呢,帮帮吧修改下代码
        <application   
            android:icon="@drawable/icon"      
            android:label="@string/app_name"         
             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
            <activity android:name=".MyActivity" android:label="@string/app_name"
                android:icon="@drawable/icon"    >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
        </application>
      

  7.   

    我的做法是在项目中为每种控件设置一个style,然后应用到该类型的控件上,这样就可以保持样式的统一,也好修改,某些控件需要特殊设置的话也可以直接设置对应的属性即可,很方便
      

  8.   

    项目目录知道的吧,styles文件在哪应该是知道的吧。
    AndroidManifest.xml知道吧    <application
                android:allowBackup="true"
                android:icon="@drawable/ic_launcher"
                android:label="场(厂)内专用机动车辆定期监督检验"
                android:theme="@style/AppTheme">
      

  9.   


    AndroidManifest.xml知道吧    <application
                android:allowBackup="true"
                android:icon="@drawable/ic_launcher"
                android:label="场(厂)内专用机动车辆定期监督检验"
                android:theme="@style/AppTheme">

    兄弟,你看你都回答了两次了,再加点力,这100分肯定是你的了,
    问题是你看,我的AndroidManifest.xml里已用了  一种主题android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    ,请问怎么能同时用两种主题  
    android:theme="@style/AppTheme"
      

  10.   

    style已经算是最有效的了,你可以把一些设置相同的属性写入,然后你只需在每个控件中引用style就行了
      

  11.   

    给你个范例<TextView
                            style="@style/right_triangle"
                            android:layout_centerVertical="true"
                            android:layout_marginRight="14dip" />
    <EditText
                            style="@style/right_triangle"
                            android:layout_centerVertical="true"
                            android:layout_marginRight="14dip" />
    <style name="wrap">
            <item name="android:layout_width">wrap_content</item>
            <item name="android:layout_height">wrap_content</item>
        </style>
    <style name="right" parent="wrap">
            <item name="android:layout_marginRight">10dip</item>
            <item name="android:layout_centerVertical">true</item>
            <item name="android:layout_alignParentRight">true</item>
        </style>
    <style name="right_triangle" parent="right">
            <item name="android:textsize">16sp</item>
        </style>这样textview和edittext的textsize,layout_marginRight,layout_centerVertical,layout_alignParentRight,layout_width,layout_height就都设置好了,如果你在<EditText
                            style="@style/right_triangle"
                            android:layout_centerVertical="true"
                            android:layout_marginRight="14dip" />这里有设置了以上属性,类似重写,子类的起作用,style里的对应属性就不起作用了
      

  12.   

    <style name="wrap">
            <item name="android:layout_width">wrap_content</item>
            <item name="android:layout_height">wrap_content</item>
        </style>
    <style name="right" parent="wrap">
            <item name="android:layout_marginRight">10dip</item>
            <item name="android:layout_centerVertical">true</item>
            <item name="android:layout_alignParentRight">true</item>
        </style>
    <style name="right_triangle" parent="right">
            <item name="android:textsize">16sp</item>
        </style>
    这些放在values目录下的styles.xml中