Android:UI控件RatingBar、SeekBar、ProgressBar、RadioGroup、RadioButton、CheckBox、TextView

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
public  class  MainActivity  extends  Activity  implements  OnClickListener
{
                                                                                                                                                                                                                                                                                                                                                                                                                                                    
     @Override
     protected  void  onCreate(Bundle savedInstanceState)
     {
         super .onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
                                                                                                                                                                                                                                                                                                                                                                                                                                                        
         findViewById(R.id.button1).setOnClickListener( this );
         findViewById(R.id.button2).setOnClickListener( this );
         findViewById(R.id.button3).setOnClickListener( this );
         findViewById(R.id.button4).setOnClickListener( this );
         findViewById(R.id.button5).setOnClickListener( this );
         findViewById(R.id.button6).setOnClickListener( this );
     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                    
     @Override
     public  boolean  onCreateOptionsMenu(Menu menu)
     {
         getMenuInflater().inflate(R.menu.activity_main, menu);
         return  true ;
     }
     @Override
     public  void  onClick(View v)
     {
         switch  (v.getId())
         {
         case  R.id.button1:
             btn1Click();
             break ;
         case  R.id.button2:
             btn2Click();
             break ;
         case  R.id.button3:
             btn3Click();
             break ;
         case  R.id.button4:
             btn4Click();
             break ;
         case  R.id.button5:
             btn5Click();
             break ;
         case  R.id.button6:
             btn6Click();
             btn7Click();
             break ;
         default :
             break ;
         }
     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                    
     private  void  btn7Click() //评分条
     {
         RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar1);
         ratingBar.setNumStars( 5 );
         ratingBar.setRating(( float 0.5 ); //默认显示的星星数
         ratingBar.setOnRatingBarChangeListener( new  OnRatingBarChangeListener()
         {
             @Override
             public  void  onRatingChanged(RatingBar ratingBar,  float  rating, boolean  fromUser)
             {
                 Log.e( "RatingBar" "onRatingChanged:"  + rating);
             }
         });
     }
     private  void  btn6Click() //可操作进度条
     {
          SeekBar seekBar= (SeekBar) findViewById(R.id.seekBar1);
          seekBar.setOnSeekBarChangeListener( new  OnSeekBarChangeListener()
         {
             @Override
             public  void  onStopTrackingTouch(SeekBar seekBar) //停止拖动
             {
                 Log.e( "SeekBar" "onStopTrackingTouch" );
             }
                                                                                                                                                                                                                                                                                                                                                                                                                                                            
             @Override
             public  void  onStartTrackingTouch(SeekBar seekBar) //开始拖动
             {
                 Log.e( "SeekBar" "onStartTrackingTouch" );
             }
                                                                                                                                                                                                                                                                                                                                                                                                                                                            
             @Override //进度改变
             public  void  onProgressChanged(SeekBar seekBar,  int  progress, boolean  fromUser)
             {
                 Log.e( "SeekBar" "onProgressChanged" );
             }
         });
     }
     private  int  progress =  0 ;
     private  void  btn5Click() //进度条
     {
         ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar2);
         progressBar.setProgress(progress++);
         progressBar.setMax( 100 );
     }
     private  void  btn4Click() // 单选按钮
     {
         RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radioGroup1);
         int  id = radioGroup.getCheckedRadioButtonId();
         RadioButton radioButton = (RadioButton) findViewById(id);
         String str = radioButton.getText().toString();
         TextView textView = (TextView) findViewById(R.id.textView1);
         switch  (id)
         {
         case  R.id.radio0:
             textView.setText(str);
             break ;
         case  R.id.radio1:
             textView.setText(str);
             break ;
         case  R.id.radio2:
             textView.setText(str);
             break ;
         default :
             break ;
         }
     }
     private  void  btn3Click() //设置圆形进度条消失(不占位置)
     {
         findViewById(R.id.progressBar1).setVisibility(View.GONE);
     }
     private  void  btn2Click() //设置圆形进度条为隐形(原位置空白)
     {
         findViewById(R.id.progressBar1).setVisibility(View.INVISIBLE);
     }
     private  void  btn1Click() //复选框
     {
         CheckBox checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
         CheckBox checkBox2 = (CheckBox) findViewById(R.id.checkBox2);
         CheckBox checkBox3 = (CheckBox) findViewById(R.id.checkBox3);
         TextView textView = (TextView) findViewById(R.id.textView1);
         StringBuffer str =  new  StringBuffer();
         if (checkBox1.isChecked())
         {
             str.append(checkBox1.getText());
         }
         if (checkBox2.isChecked())
         {
             str.append(checkBox2.getText());
         }
         if (checkBox3.isChecked())
         {
             str.append(checkBox3.getText());
         }
         textView.setText(str);
     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                    
}



1.代码实现按钮点击方法

1
button.PerformClick()

注:只有当button.Enabled为true




==============================UI控件属性相关==============================


控件自定义:

1.圆形progressbar

系统styles里找到progressbar的style属性:

1
2
3
4
5
6
7
8
9
<style name= "Widget.ProgressBar" >
<item name= "android:indeterminateOnly" > true </item>
<item name= "android:indeterminateDrawable" > @android :drawable/progress_medium_white</item>
<item name= "android:indeterminateBehavior" >repeat</item>
<item name= "android:indeterminateDuration" > 3500 </item>
<item name= "android:minWidth" >48dip</item>
<item name= "android:maxWidth" >48dip</item>
<item name= "android:minHeight" >48dip</item>
<item name= "android:maxHeight" >48dip</item>


其中,下面这句决定背景图案的设置,这个属性添加到控件的属性里:

1
<item name= "android:indeterminateDrawable" >@android:drawable/progress_medium_white</item>


将系统的drawable文件夹找到progress_medium_white.xml复制到自己的项目里,并进行修改:

1
2
3
4
5
<animated-rotate xmlns:android= "http://schemas.android.com/apk/res/android"
  android:drawable= "@drawable/ic_launcher"
  android:pivotX= "50%"
  android:pivotY= "50%"
/>



2.进度progressbar

系统style文件内容:

1
2
3
4
5
6
<style name= "Widget.ProgressBar.Horizontal" >
        <item name= "android:indeterminateOnly" > false </item>
         <item name= "android:progressDrawable" > @android :drawable/progress_horizontal</item>
          <item name= "android:indeterminateDrawable" > @android :drawable/progress_indeterminate_horizontal</item>
           <item name= "android:minHeight" >20dip</item>
           <item name= "android:maxHeight" >20dip</item>


关联的属性为:

1
name= "android:progressDrawable"


修改progress_horizontal.xml:

1
2
3
4
5
6
7
8
<layer-list xmlns:android= "http://schemas.android.com/apk/res/android" >
  <item android:id= "@android:id/background"  android:drawable= "@drawable/progress_bg" >
  </item>
  <item android:id= "@android:id/secondaryProgress"  android:drawable= "@drawable/progress_second" >
  </item>
  <item android:id= "@android:id/progress"  android:drawable= "@drawable/progress_color" >
  </item>
  </layer-list>


控件基本属性:

(1)修改属性style

1
style= "?android:attr/progressBarStyleHorizontal"

(2)最大进度值为100

1
android:max= "100"

(3)初始化的进度值

1
android:secondaryProgress= "70"

(4)设置为无限进度

1
android:indeterminate= "true"

(5)代码设置样式

1
2
3
4
5
ProgressBar progressBar =  new  ProgressBar( this );
         progressBar.setIndeterminate( false );
         progressBar.setProgressDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
         progressBar.setIndeterminateDrawable(getResources().getDrawable(android.R.drawable.progress_indeterminate_horizontal));
         progressBar.setMinimumHeight( 20 );



3.seekbar:

类似于progressbar,只是多了个拖动按钮。

添加一个thumb属性:实际上是个selector的按钮。


4.ratingbar:

搜索ratingbar的xml文件进行修改,关联属性:progressDrawable。

以4.2版本里ratingbar_full_holo_dark的风格为例:


ratingbar_full_empty_holo_dark.xml代码:

1
2
3
4
5
6
7
8
9
10
11
12
<selector xmlns:android= "http://schemas.android.com/apk/res/android" >
     <item android:state_pressed= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_off_pressed_holo_dark"  />
     <item android:state_focused= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_off_focused_holo_dark"  />
     <item android:state_selected= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_off_focused_holo_dark"  />
     <item android:drawable= "@drawable/btn_rating_star_off_normal_holo_dark"  />
</selector>


ratingbar_full_filled_holo_dark.xml代码:

1
2
3
4
5
6
7
8
9
10
11
12
<selector xmlns:android= "http://schemas.android.com/apk/res/android" >
     <item android:state_pressed= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_on_pressed_holo_dark"  />
     <item android:state_focused= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_on_focused_holo_dark"  />
     <item android:state_selected= "true"
           android:state_window_focused= "true"
           android:drawable= "@drawable/btn_rating_star_on_focused_holo_dark"  />
     <item android:drawable= "@drawable/btn_rating_star_on_normal_holo_dark"  />
</selector>


rating_style.xml代码:

1
2
3
4
5
<layer-list xmlns:android= "http://schemas.android.com/apk/res/android"  >
     <item android:id= "@+android:id/background"  android:drawable= "@drawable/ratingbar_full_empty_holo_dark"  />
     <item android:id= "@+android:id/secondaryProgress"  android:drawable= "@drawable/ratingbar_full_empty_holo_dark"  />
     <item android:id= "@+android:id/progress"  android:drawable= "@drawable/ratingbar_full_filled_holo_dark"  />
</layer-list>


XML文件代码:

1
2
3
4
5
6
7
8
<RatingBar
     android:id= "@+id/ratingBar1"
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:progressDrawable= "@drawable/rating_style"
     android:layout_alignParentBottom= "true"
     android:layout_centerHorizontal= "true"
     android:layout_marginBottom= "35dp"  />



5.checkbox和radiobutton:

checkbox可以直接添加一个属性修改为star风格:

1
android:style= "?android:attr/starStyle"


关联属性:

1
android:button= "@drawable/checkbox_selector"


XML代码:

1
2
3
4
5
6
7
8
9
<CheckBox
         android:id= "@+id/checkBox1"
         android:layout_width= "wrap_content"
         android:layout_height= "wrap_content"
         android:layout_alignParentTop= "true"
         android:layout_centerHorizontal= "true"
         android:layout_marginTop= "58dp"
         android:button= "@drawable/checkbox_selector"
         android:text= "CheckBox"  />


selector代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version= "1.0"  encoding= "utf-8" ?>
<selector xmlns:android= "http://schemas.android.com/apk/res/android"  >
     <item android:state_checked= "true"
         android:state_pressed= "false"
         android:drawable= "@drawable/checkbox_cart_goods_on" ></item>
     <item android:state_checked= "true"
         android:state_pressed= "true"
         android:drawable= "@drawable/checkbox_on" ></item>
     <item android:state_checked= "false"
         android:state_pressed= "true"
         android:drawable= "@drawable/checkbox_off" ></item>
     <item android:state_checked= "false"
         android:state_pressed= "false"
         android:drawable= "@drawable/checkbox_normal" ></item>
</selector>



监听事件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
         mIv_CheckXieyi.setOnCheckedChangeListener( new  CompoundButton.OnCheckedChangeListener()
         {
             @Override
             public  void  onCheckedChanged(CompoundButton buttonView,  boolean  isChecked)
             {
                 if (isChecked)
                 {
                     Log.e( "" "updateCheckBox===false" );
                 }
                 else
                 {
                     Log.e( "" "updateCheckBox===true" );
                 }
             }
         });


注:

  1. 左侧的图案直接使用button无法出现时,可使用drawableLeft设置,如下:

1
2
3
4
5
6
7
8
9
             <RadioButton
                 android:id= "@+id/routemenu_tab_walk"
                 style= "@style/tab_title_maproute"
                 android:drawableLeft= "@drawable/selector_route_walk"
                 android:layout_width= "match_parent"
                 android:layout_height= "wrap_content"
                 android:layout_weight= "1"
                 android:background= "@drawable/selector_tab_bg_left"
                 android:text= "步行"  />


其中tab_title_maproute.xml代码如下:

1
2
3
4
5
6
7
8
9
10
     <style name= "tab_title_maproute"  parent= "tab_title_newslist" >
         <item name= "android:button" > @null </item>
         <item name= "android:paddingLeft" >8dp</item>
         <item name= "android:paddingRight" >8dp</item>
         <item name= "android:textColor" > @color /white</item>
         <item name= "android:textSize" >15sp</item>
         <item name= "android:height" > @dimen /photo_gallery_tab_hight</item>
         <item name= "android:background" > @drawable /selector_tab_bg_center</item>
         <item name= "android:gravity" >center</item>
     </style>


其中selector_route_walk.xml代码如下:

1
2
3
4
5
6
7
8
9
10
<?xml version= "1.0"  encoding= "utf-8" ?>
<selector xmlns:android= "http://schemas.android.com/apk/res/android"  >
     <item android:state_checked= "true"
         android:drawable= "@drawable/route_walk_nor" ></item>
     <item android:state_pressed= "true"
         android:drawable= "@drawable/route_walk_nor" ></item>
     <item android:state_selected= "true"
         android:drawable= "@drawable/route_walk_nor" ></item>
<item android:drawable= "@drawable/route_walk_pressed" ></item>
</selector>






6.TextView相关:

(1)DrawableTop在代码中的实现方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public  View getView( int  position, View convertView, ViewGroup parent)
{
     LayoutInflater inflater = getLayoutInflater();
     TextView textView =  null ;
     if  (position ==  0  || position ==  2  || position ==  8 )
     {
         textView = (TextView) inflater.inflate(
                 R.layout.navi_menu_item_separator,  null );
     }
     else
     {
          textView = (TextView) inflater.inflate(
                 R.layout.navi_menu_item,  null );
          Drawable drawable = getResources().getDrawable(ICONS[position]);
          drawable.setBounds( 0 0 , drawable.getMinimumWidth(), drawable.getMinimumHeight());
          textView.setCompoundDrawables(drawable,  null null null ); //四个参数分别对应为上下左右,相当于xml里对textview设置drawabletop
     }
     textView.setText(TITLES[position]);
     return  textView;
}


(2)文本添加链接功能的属性autolink:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@Override
protected  void  onCreate(Bundle savedInstanceState)
{
     super .onCreate(savedInstanceState);
                                                                                                                         
     setContentView(R.layout.link);
                                                                                                                                 
     /*
      * APIdemo里:com.example.android.apis.text;
      */
     SpannableString ss =  new  SpannableString( "text4: Manually created spans. Click here to dial the phone." );
                                                                                                                         
     ss.setSpan( new  StyleSpan(Typeface.BOLD),  0 30 , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  // setSpan方法可以用来根据判断文本位置设置文本特定类型
                                                                                                                         
     ss.setSpan( new  URLSpan( "tel:4155551212" ),  31  6 31  10 , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                                                                                                                         
     TextView t4 = (TextView) findViewById(R.id.text4);
     t4.setText(ss);
     t4.setMovementMethod(LinkMovementMethod.getInstance());
}


(3)为文字加阴影

1
2
3
4
5
6
7
8
9
10
11
12
<TextView  android:id= "@+id/tvText1"
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:text= "text1"
     android:textSize= "28sp"
     android:textStyle= "bold"
     android:textColor= "#FFFFFF"
     android:shadowColor= "#ff000000"    //阴影颜色
     android:shadowDx= "2"               //阴影的水平偏移量
     android:shadowDy= "2"               //阴影的垂直偏移量
     android:shadowRadius= "1"           //阴影的范围
/>



(4)添加下划线

如果是在资源文件里,可以这样写:

1
2
3
4
5
  
<resources>
     <string name= "hello" ><u>phone:  1390123456 </u></string>
     <string name= "app_name" >MyLink</string>
</resources>


如果是代码这样写.

1
2
TextView textView = (TextView)findViewById(R.id.testView); 
textView.setText(Html.fromHtml( "<u>" + "hahaha" + "</u>" ));

或者也可以这样写:

1
textview.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线


(5)通过字符串格式拼凑文本

1
2
3
4
String content = TextUtil.preventEmpty(comment.content);
String replyToUserName = comment.replyToUser.username;
String ContentBody = APP.getInstance().getString(R.string.discuss_content,replyToUserName,content);
tvDiscussContent.setText(ContentBody); 


xml资源内写法:

1
     <string name= "discuss_content" >回复 % 1 $s : % 2 $s </string>


(6)设置部分字体颜色

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
textView = (TextView) findViewById(R.id.textview);
SpannableStringBuilder builder =  new  SpannableStringBuilder(textView.getText().toString());
 
//ForegroundColorSpan 为文字前景色,BackgroundColorSpan为文字背景色
ForegroundColorSpan redSpan =  new  ForegroundColorSpan(Color.RED);
ForegroundColorSpan whiteSpan =  new  ForegroundColorSpan(Color.WHITE);
ForegroundColorSpan blueSpan =  new  ForegroundColorSpan(Color.BLUE);
ForegroundColorSpan greenSpan =  new  ForegroundColorSpan(Color.GREEN);
ForegroundColorSpan yellowSpan =  new  ForegroundColorSpan(Color.YELLOW);
 
builder.setSpan(redSpan,  0 1 , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(whiteSpan,  1 2 , Spannable.SPAN_INCLUSIVE_INCLUSIVE);
builder.setSpan(blueSpan,  2 3 , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(greenSpan,  3 4 , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(yellowSpan,  4 , 5 , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 
textView.setText(builder);


(7)设置style:

1
textView.setTextAppearance(mContext, R.style.labels);


(8)长按复制,api>11

1
android:textIsSelectable= "true"




6.EditText相关:

1.设置默认提示:

1
2
android:hint= "请输入姓名"
android:textColorHint= "#ff00ff00"


android:background="@null"去掉输入框




2.取消焦点和请求焦点方法

1
2
             //取消焦点
             mEt_login_name.setFocusable( false );
1
2
3
4
             //请求焦点
             mEt_login_name.setFocusableInTouchMode( true );
             mEt_login_name.setFocusable( true );
             mEt_login_name.requestFocus();



3.监听编辑框字数

1
2
3
         // 字数变化
         mEt_content.addTextChangedListener( this );
         onTextChanged(mEt_content.getText(),  0 , mEt_content.length(),  0 );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
     /**
      * ******************监听编辑框输入字数**********************************
      */
     @Override
     public  void  afterTextChanged(Editable s)
     {
     }
     
     @Override
     public  void  beforeTextChanged(CharSequence s,  int  start,  int  count,  int  after)
     {
     }
     
     @Override
     public  void  onTextChanged(CharSequence s,  int  start,  int  before,  int  count)
     {
         int  remain = MAX_TEXT_COUNT - mEt_content.length();
         mTv_counter.setText(String.valueOf(remain));
         mTv_counter.setTextColor(remain >  0  0xffcfcfcf  0xffff0000 );
     }


4.监听编辑框输入回车键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
         mEt_jianhuo.setOnKeyListener( new  OnKeyListener()
         {
             @Override
             public  boolean  onKey(View v,  int  keyCode, KeyEvent event)
             {
                 if  (KeyEvent.KEYCODE_ENTER == keyCode && event.getAction() == KeyEvent.ACTION_DOWN)
                 {
                     Log.e( "mEt_jianhuo" "enter" );
                     saoMaCheckedToServer(mEt_jianhuo.getText().toString() +  "" , mData.getId() +  "" , isUseAvg());
                     return  true ;
                 }
                 
                 return  false ;
             }
         });


5.设置软键盘回车键显示为"下一条"或者"完成"等

主要属性:

imeActionLabel

imeOptions

singleLine


1
2
3
4
5
6
7
8
9
10
             <EditText
                 android:id= "@+id/hm_saoma_et_quxiao"
                 android:layout_width= "wrap_content"
                 android:layout_height= "40dp"
                 android:layout_weight= "1"
                 android:imeOptions= "actionNext"
                 android:imeActionLabel= "下一条"
                 android:singleLine= "true"
                 android:ems= "15"
                 />
1
2
3
4
5
6
7
8
9
             <EditText
                 android:id= "@+id/hm_saoma_et_quxiao"
                 android:layout_width= "wrap_content"
                 android:layout_height= "40dp"
                 android:layout_weight= "1"
                 android:ems= "15"
                 android:imeActionLabel= "完成"
                 android:imeOptions= "actionDone"
                 android:singleLine= "true"  />





本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1200354,如需转载请自行联系原作者
目录
相关文章
|
2月前
|
搜索推荐 Android开发 开发者
探索安卓开发中的自定义视图:打造个性化UI组件
【10月更文挑战第39天】在安卓开发的世界中,自定义视图是实现独特界面设计的关键。本文将引导你理解自定义视图的概念、创建流程,以及如何通过它们增强应用的用户体验。我们将从基础出发,逐步深入,最终让你能够自信地设计和实现专属的UI组件。
|
24天前
|
移动开发 前端开发 Java
Java最新图形化界面开发技术——JavaFx教程(含UI控件用法介绍、属性绑定、事件监听、FXML)
JavaFX是Java的下一代图形用户界面工具包。JavaFX是一组图形和媒体API,我们可以用它们来创建和部署富客户端应用程序。 JavaFX允许开发人员快速构建丰富的跨平台应用程序,允许开发人员在单个编程接口中组合图形,动画和UI控件。本文详细介绍了JavaFx的常见用法,相信读完本教程你一定有所收获!
Java最新图形化界面开发技术——JavaFx教程(含UI控件用法介绍、属性绑定、事件监听、FXML)
|
19天前
|
前端开发 Linux C#
一款开源、免费、美观的 Avalonia UI 原生控件库 - Semi Avalonia
一款开源、免费、美观的 Avalonia UI 原生控件库 - Semi Avalonia
55 10
|
1月前
|
XML 搜索推荐 前端开发
安卓开发中的自定义视图:打造个性化UI组件
在安卓应用开发中,自定义视图是一种强大的工具,它允许开发者创造独一无二的用户界面元素,从而提升应用的外观和用户体验。本文将通过一个简单的自定义视图示例,引导你了解如何在安卓项目中实现自定义组件,并探讨其背后的技术原理。我们将从基础的View类讲起,逐步深入到绘图、事件处理以及性能优化等方面。无论你是初学者还是有经验的开发者,这篇文章都将为你提供有价值的见解和技巧。
|
2月前
|
XML 前端开发 Android开发
Android:UI:Drawable:View/ImageView与Drawable
通过本文的介绍,我们详细探讨了Android中Drawable、View和ImageView的使用方法及其相互关系。Drawable作为图像和图形的抽象表示,提供了丰富的子类和自定义能力,使得开发者能够灵活地实现各种UI效果。View和ImageView则通过使用Drawable实现了各种图像和图形的显示需求。希望本文能为您在Android开发中使用Drawable提供有价值的参考和指导。
51 2
|
2月前
|
人工智能 API Apache
推荐3款开源、美观且免费的WinForm UI控件库
推荐3款开源、美观且免费的WinForm UI控件库
487 6
|
2月前
|
API C# 开发者
基于Material Design风格开源、免费的WinForms UI控件库
基于Material Design风格开源、免费的WinForms UI控件库!
|
3月前
|
Linux C# Android开发
分享3款开源、免费的Avalonia UI控件库
分享3款开源、免费的Avalonia UI控件库
341 0
|
4月前
|
XML Android开发 UED
💥Android UI设计新风尚!掌握Material Design精髓,让你的界面颜值爆表!🎨
随着移动应用市场的蓬勃发展,用户对界面设计的要求日益提高。为此,掌握由Google推出的Material Design设计语言成为提升应用颜值和用户体验的关键。本文将带你深入了解Material Design的核心原则,如真实感、统一性和创新性,并通过丰富的组件库及示例代码,助你轻松打造美观且一致的应用界面。无论是色彩搭配还是动画效果,Material Design都能为你的Android应用增添无限魅力。
108 1
|
3月前
|
XML 存储 Java
浅谈Android的TextView控件
浅谈Android的TextView控件
50 0

热门文章

最新文章