Android中自定义buttom样式在item中的调用
2017-02-18 10:30
232 查看
一、在drawable目录下新建一个drawableresourcefile(selector)
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/bg_normalbutton" android:state_pressed="false"></item> <item android:drawable="@drawable/bg_pressbutton" android:state_pressed="true"></item> <item android:drawable="@drawable/bg_normalbutton"></item> </selector>
二、在drawable目录下新建一个drawableresourcefile(shape)
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1dp"//设置边框 android:color="@color/colorPrimaryDark"></stroke> <solid android:color="#b878fd"></solid>//设置颜色 <corners android:radius="5dp"></corners>//设置圆角 </shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1dp" android:color="@color/colorAccent"></stroke> <solid android:color="#ff2244"></solid> <corners android:radius="5dp"></corners> </shape>
三、调用方法 可以在自定义的item布局文件中作文背景图片调用
相关文章推荐
- Android 自定义ListView格局和各Item的样式
- 改变listview的item项的颜色、自定义expandlistview的group、item的颜色,改变、调用android.R.layout参数
- Android中自定义dialog方法,可直接调用,更改样式
- android自定义弹出框样式实现
- Android 中怎么设置全局自定义字体样式
- Android自定义样式对话框Dialog
- Android Notification自定义样式
- Android自定义组件之日历控件-精美日历实现(内容、样式可扩展)
- android自定义接口,然后在activity中实现点击监听,调用getView解决滑动错位的问题
- Android 自定义RadioButton的样式
- Android控件之RatingBar自定义星级评分样式
- androidRadioButton 自定义样式
- Android 中自定义分享样式弹窗
- Android中自定义样式与View的构造函数中的第三个参数defStyle的意义
- Android的SeekBar自定义样式
- Android知识整理(3) 两种自定义样式的Checkbox
- Android中的自定义Adapter(继承自BaseAdapter)——与系统Adapter的调用方法一致——含ViewHolder显示效率的优化
- Android 自定义progressBar样式
- (转)Android: 自定义Tab样式
- Android滚轮控件,基于ListView实现,可以自定义样式。