有没有一种方法可以将样式应用于布局xml中特定类型的所有元素,而无需实际将样式属性添加到所有元素?
我在GrIDLayout中有很多TextVIEw元素.如果我可以说所有TextVIEw元素都应具有样式“ CellFont”,而不必实际上将该语句放入每个TextVIEw元素中,那将是很好的.
解决方案如下:
将GrIDLayoutCellFont样式添加到style.xml,并将该样式作为android:theme添加到应用程序清单中的Activity中.
style.xml:
<?xml version="1.0" enCoding="utf-8"?><resources> <style name="GrIDLayoutCellFont"> <item name="androID:textSize">22dp</item> </style></resources>
表现:
<application androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" > <activity androID:theme="@style/GrIDLayoutCellFont" androID:label="@string/app_name" androID:name=".TestLayoutsActivity" > <intent-filter > <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity></application>
解决方法:
您可以使用样式或设置新主题的两个选项,请参见Styles and Themes教程.
总结以上是内存溢出为你收集整理的android-将样式设置为布局中所有TextView元素的位置全部内容,希望文章能够帮你解决android-将样式设置为布局中所有TextView元素的位置所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)