欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

Android 开发笔记___drawable

发布时间:2023/12/10 49 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Android 开发笔记___drawable 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

 

1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical"> 6 7 <Button 8 android:layout_width="wrap_content" 9 android:layout_height="wrap_content" 10 android:layout_gravity="center" 11 android:layout_margin="10dp" 12 android:text="默认样式的按钮" 13 android:textColor="#000000" 14 android:textSize="17sp" /> 15 16 <Button 17 android:layout_width="wrap_content" 18 android:layout_height="wrap_content" 19 android:layout_gravity="center" 20 android:layout_margin="10dp" 21 android:paddingLeft="8dp" 22 android:paddingRight="8dp" 23 android:background="@drawable/btn_nine_selector" 24 android:text="定制样式的按钮" 25 android:textColor="#000000" 26 android:textSize="17sp" /> 27 28 </LinearLayout>

selector

1 <?xml version="1.0" encoding="utf-8"?> 2 <selector xmlns:android="http://schemas.android.com/apk/res/android"> 3 <item android:state_pressed="true" android:drawable="@drawable/button_pressed" /> 4 <item android:drawable="@drawable/button_normal" /> 5 </selector>

java

1 package com.example.alimjan.hello_world; 2 3 import android.app.Activity; 4 import android.content.Context; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.support.annotation.Nullable; 8 9 /** 10 * Created by alimjan on 7/1/2017. 11 */ 12 13 public class class__2_4_1_1 extends Activity { 14 @Override 15 protected void onCreate(@Nullable Bundle savedInstanceState) { 16 super.onCreate(savedInstanceState); 17 setContentView(R.layout.code_2_4_1_1); 18 } 19 public static void startHome(Context mContext) { 20 Intent intent = new Intent(mContext, class__2_4_1_1.class); 21 mContext.startActivity(intent); 22 } 23 }
状态类型说明常用的控件
state_pressed是否按下按钮button
state_checked是否勾选单选框RadioButton、复选框chenckBox
state_focused是否获取焦点文本编辑框Edittext
state_selected是否选中

各控件均可

转载于:https://www.cnblogs.com/alimjan/p/7102092.html

总结

以上是生活随笔为你收集整理的Android 开发笔记___drawable的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。