如何对多个按钮统一设置属性? 我有差不多10个控件,但是我想把这十个都统一设置背景颜色。 如果是一个一个设置的话会很麻烦,不知道大家 是怎么弄这个问题的呢?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 android res/values/styles.xml文件可以定义统一的样式比如 styles.xml代码如下: <style name="backgroundformyapp"> <item name="android:background">背景</item> </style>布局文件中的控件引用,比如ImageView,Button设置背景 <ImageView style="@style/backgroundformyapp" /> <Button style="@style/backgroundformyapp" /> 你没有自定义过控件吗?定义过啊,在布局文件 <Button android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/A01ID" android:text="@string/A1Text" />这种还不算吗? 你没有自定义过控件吗?定义过啊,在布局文件 <Button android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/A01ID" android:text="@string/A1Text" />这种还不算吗?不算,我说的是重写button这个类,统一设置背景色.类似于这个 <com.test.ButtonTest android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/A01ID" android:text="@string/A1Text" />如果只是单一的改变背景色,用2楼的方法就行了.. 这种貌似还是不行啊, <Button style="@style/backgroundformyapp" />你这个还是需要 单个设置Button的背景啊。。我想问的是全部Button控件统一设置就是只要设置一次,就所有的控件都变成统一的背景的那种谢谢。。 这种貌似还是不行啊, <Button style="@style/backgroundformyapp" />你这个还是需要 单个设置Button的背景啊。。我想问的是全部Button控件统一设置就是只要设置一次,就所有的控件都变成统一的背景的那种谢谢。。那你从写android的Button类,重新设置背景就可以了。 初学者救急 关于android手机显示显示多字段表格数据的问题 转一个不错的andriod2.0游戏开发宝典资源,觉得不错! 全屏后 无法接收点击事件 如何去掉几个ImageButton之间的空隙 想做个能查询学校分数的应用。可不知道怎么弄 monkeyrunner 测试 只能通过ID来获取控件? 关于SDK自带的bluetoothchat的源码错误问题 webView怎么在所加载的页面初始化的时候执行一段js? android EventBus偶尔传递不了消息 有大神在吗,在XML中对RelativeLayout设置onClick,然后报错 android播放器怎么调用硬解
比如 styles.xml代码如下:
<style name="backgroundformyapp">
<item name="android:background">背景</item>
</style>
布局文件中的控件引用,比如ImageView,Button设置背景
<ImageView style="@style/backgroundformyapp" />
<Button style="@style/backgroundformyapp" />
定义过啊,在布局文件 <Button
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/A01ID"
android:text="@string/A1Text"
/>这种还不算吗?
定义过啊,在布局文件 <Button
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/A01ID"
android:text="@string/A1Text"
/>这种还不算吗?不算,我说的是重写button这个类,统一设置背景色.类似于这个
<com.test.ButtonTest
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/A01ID"
android:text="@string/A1Text"
/>
如果只是单一的改变背景色,用2楼的方法就行了..
<Button style="@style/backgroundformyapp" />
你这个还是需要 单个设置Button的背景啊。。
我想问的是全部Button控件统一设置
就是只要设置一次,就所有的控件都变成统一的背景的那种
谢谢。。
<Button style="@style/backgroundformyapp" />
你这个还是需要 单个设置Button的背景啊。。
我想问的是全部Button控件统一设置
就是只要设置一次,就所有的控件都变成统一的背景的那种
谢谢。。那你从写android的Button类,重新设置背景就可以了。