(android 基础知识) android Button 自定义点击效果
2014-08-14 11:10
113 查看
第一步:drawable文件夹下创建select.xml文件
第二步:在布局文件中引用相关自定义样式文件
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/login_btn" /> <item android:state_focused="false" android:drawable="@drawable/login_btn_focused" /> </selector>
第二步:在布局文件中引用相关自定义样式文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/login_back" > <LinearLayout android:layout_width="fill_parent" android:layout_height="200dp" android:gravity="center|top" android:layout_marginTop="100dp" android:orientation="vertical"> <ImageView android:layout_width="260dp" android:layout_height="wrap_content" android:src="@drawable/login_logo" android:layout_margin="20dp"> </ImageView> <EditText android:id="@+id/zhanghao_edit" android:layout_width="220dp" android:layout_height="39dp" android:background="@drawable/shouji_edit" android:focusable="true" android:paddingLeft="1dp" > </EditText> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center"> <TextView android:layout_width="145dp" android:layout_height="wrap_content" android:text="请输入本机号码" android:id="@+id/login_shoujihao_textview" android:textColor="#ffffff"> </TextView> <Button android:layout_width="72dp" android:layout_height="32dp" android:background="@drawable/<span style="color:#ff0000;">selector</span>" android:textColor="#ffffff" android:id="@+id/login_btn" android:text="确 认"> </Button> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_marginBottom="10dp" android:gravity="bottom"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="长沙云轩信息技术有限公司" android:textSize="12sp" android:gravity="center" android:textColor="#ffffff"> </TextView> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="www.vixuan.com" android:textSize="12sp" android:gravity="center" android:textColor="#ffffff"> </TextView> </LinearLayout> </LinearLayout>
相关文章推荐
- Android中的Button自定义点击效果
- Android中的Button自定义点击效果
- android笔记 自定义textview,button等控件的外观,点击效果
- Android自定义Button的点击效果
- Android基础:listview的item点击事件会使里面的Button也出现按压的效果
- android自定义button点击效果
- Android中的Button自定义点击效果
- Android中的Button自定义点击效果
- Android中的Button自定义点击效果
- Android之Button自定义点击效果
- Android中Button自定义点击效果
- Android中的Button自定义点击效果实例代码
- Android之Button自定义点击效果
- Android自定义Button的点击效果
- Android之Button自定义点击效果
- Android之Button自定义点击效果
- Android之Button自定义点击效果
- Android中的Button自定义点击效果
- Android中的Button自定义点击效果
- Android之Button自定义点击效果