界面上有几种控件:一些Button ,一些TextView , 还有点TexEdit,它们的字体太小,一个一个设置太麻烦,有没有简单的代码可统一次设定
界面上有几种控件:一些Button ,一些TextView , 还有些TexEdit,它们的字体太小,一个一个设置太麻烦,有没有简单的代码可统一次设定?
如题!!!谢谢!!!
请给出代码,给代码有分,谢谢!!!
------解决思路----------------------
写个样式 放在style.xml里面,字体大小和颜色 都是放在values目录下面配置成常量。
------解决思路----------------------
你的界面使用的样式中加入一个全局字体样式。 这样所有未设置字体大小的,全部会使用这个字体大小了
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
你要在配置文件里使用这个主题才有效果
------解决思路----------------------
我的做法是在项目中为每种控件设置一个style,然后应用到该类型的控件上,这样就可以保持样式的统一,也好修改,某些控件需要特殊设置的话也可以直接设置对应的属性即可,很方便
------解决思路----------------------
项目目录知道的吧,styles文件在哪应该是知道的吧。
AndroidManifest.xml知道吧
------解决思路----------------------
2个主题的内容合并到一起三
------解决思路----------------------
学习一下,也遇到类似的问题
------解决思路----------------------
给你个范例<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里的对应属性就不起作用了
如题!!!谢谢!!!
请给出代码,给代码有分,谢谢!!!
------解决思路----------------------
写个样式 放在style.xml里面,字体大小和颜色 都是放在values目录下面配置成常量。
------解决思路----------------------
你的界面使用的样式中加入一个全局字体样式。 这样所有未设置字体大小的,全部会使用这个字体大小了
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textSize">28sp</item>
</style>
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
兄弟,这个全局设置我试了下好像不行,我一般都是在每个控件中设置一个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" />
------解决思路----------------------
你要在配置文件里使用这个主题才有效果
<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>
------解决思路----------------------
我的做法是在项目中为每种控件设置一个style,然后应用到该类型的控件上,这样就可以保持样式的统一,也好修改,某些控件需要特殊设置的话也可以直接设置对应的属性即可,很方便
------解决思路----------------------
项目目录知道的吧,styles文件在哪应该是知道的吧。
AndroidManifest.xml知道吧
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="场(厂)内专用机动车辆定期监督检验"
android:theme="@style/AppTheme">
------解决思路----------------------
2个主题的内容合并到一起三
------解决思路----------------------
学习一下,也遇到类似的问题
------解决思路----------------------
给你个范例<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里的对应属性就不起作用了