android 如何设置checkbox、edittext点击前后不同样式
来源:互联网 发布:阿里云实例重装系统 编辑:程序博客网 时间:2024/06/02 05:37
checkbox
1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/duigou" android:state_checked="true"/>
<item android:drawable="@drawable/duigou0" android:state_checked="false"/>
<item android:drawable="@drawable/duigou0" />
</selector>
2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。
<style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_style</item>
</style>
3.在布局文件中使用CustomCheckboxTheme样式。
<CheckBox
android:id="@+id/remember"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CustomCheckboxTheme"
android:text="@string/remember"/>
//************************************************************************************
edittext
1.首先在drawable文件夹中添加drawable文件editview_style.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/focused" android:state_focused="true" />
<item android:drawable="@drawable/disabled" android:state_focused="false"/>
<item android:drawable="@drawable/disabled" />
</selector>
2.在values文件夹下的styles.xml文件中添加CustomEditviewTheme样式。
<style name="CustomEditviewTheme" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/editview_style</item>
</style>
3.在布局文件中使用CustomCheckboxTheme样式。
<EditText
style="@style/CustomEditviewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Contact phone"
android:inputType="phone"
android:id="@+id/EContactphone"
/>
- android 如何设置checkbox、edittext点击前后不同样式
- 设置itemcontrol的item点击前后不同状态
- android-设置EditText为密码样式
- 为CheckBox设置点击样式(button属性)
- android中设置CheckBox的样式
- android checkbox设置自定义的样式
- 【EditText】EditText密码样式设置
- 设置Android ImageView点击时的样式
- EditText 设置点击事件
- 一个TextView设置不同大小字体、EditText显示两行不同样式hint
- 如何自定义EditText样式
- android应用程序如何设置样式
- Android 利用Sharp样式设置文本框EditText圆角形状
- Android利用Sharp样式设置文本框EditText圆角形状
- 设置EditTExt前后左右的图片
- Android中checkbox控件的自定义样式设置
- android 如何设置 EditText 不换行
- android设置EditText不可编辑内容,响应点击事件
- pthread
- 论文书写---格式控制
- Android之Activity应用小例子
- BitBlt StretchBlt TransparentBlt
- C++中程序化操作虚函数列表实验
- android 如何设置checkbox、edittext点击前后不同样式
- SSH框架总结(框架分析+环境搭建+实例源码下载)--这个很值得一读~!
- 互联网通信应用定义
- 【c++】PAT (Advanced Level)1023. Have Fun with Numbers (20)
- 每一个Javascript程序员都应该了解的浮点知识
- 日期结构体
- 成为一个 PHP 专家:缺失的环节
- VisionMobile:2014年Q1移动开发者经济报告(五)2.2、地区前景
- zoj 2301 Color the Ball(区间染色,线段树+离散化)