一、Toast
Toast是一种轻量级的提示工具,可显示一行文本对用户的操作进行提示响应
用法:Toast.makeText(context,text,time).show();
context:上下文 、text:显示文本内容、time:显示时长
  Toast.LENGTH_SHORT(短时间显示)
  Toast.LENGTH_LONG(长时间显示)
例:
button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ceshi.this, "你点击了按钮", Toast.LENGTH_SHORT).show();
}
});
 
二、TextView——文本显示控件
常用属性
text    显示的文本内容 textColor     文本颜色
textSize      字体大小 singleLine    单行显示true|false
gravity  内容的重心位置 drawableLeft     文字左边显示的图片
drawableRight    文字右边显示的图片
drawableTop    文字上边显示的图片
drawableBottom   文字下边显示的图片
例:
<TextView
android:layout_width="200dp"
android:layout_height="100dp"
android:background="#00ff00"
android:id="@+id/textView2"
android:layout_alignBottom="@id/f1"
android:layout_centerInParent="true"
android:text="来一碗鱼丸粗面"
android:textColor="#f00"
android:textSize="20sp"
android:gravity="bottom|center"/>
 
常用方法
nsetText()  设置显示文字
nsetTextColor()  设置文字颜色,参数为颜色值
nsetTextSize()  设置文字尺寸,参数1为尺寸单位,2为尺寸大小
ngetText()  获取显示的文字
 
三、Button——按钮
常用属性
TextView的属性
还有一个onClick,但是这个一般用不到,
Button的方法见上面的Toast的用法
 
四、EditText——文本输入控件,继承自TextView
常用属性
inputType     限制能够输入文本类型
hint     显示的提示    值为 string
maxLength    能够输入的最大长度  值为 int
focusable    能否获取焦点  值为 boolean
lines     显示的行数  值为 int
maxLines 最大显示行数  值为 int
enable    是否可用   值为 boolean
例:
 
<EditText
android:id="@+id/edittext_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码!"
android:textSize="16sp"
android:textColor="#f00"
android:textColorHighlight="#a00000ff"
android:drawableLeft="@mipmap/ic_launcher"
android:inputType="textPassword" />
 
常用方法
setHint()  设置提示文本
setInputType()   设置输入限制类型
setFocusable()  设置能否获取焦点
setEnable()  设置是否可用
isEnable()  是否可用
具体代码:
edittext1.getText().toString();//获取EditView的文本值
edittext1.addTextChangedListener(watcher);//文本监听
private TextWatcher watcher = new TextWatcher() {
/*文本改变之前*/
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
/*当文本改变的时候*/
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
/*文本改变之后*/
@Override
public void afterTextChanged(Editable s) {
//获取已经输入的的文字总数
int currentCount = s.length();
//计算还能输入多少个字符,记住,数字不能直接写
textview1.setText(String.valueOf(max - currentCount));
}
};
五、CheckBox——复选框,继承自TextView
 
常用属性
TextView的属性
button  复选指示按钮
checked  是否选中
例:
<CheckBox
android:id="@+id/checkbox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox1"
android:text="敲代码" />
常用方法
TextView的方法
setChecked()  设置是否选中
isChecked()  是否选中的
setOnCheckedChangeListener()  设置选中改变监听
具体代码
checkboxall.setOnCheckedChangeListener(changeListener);
checkboxall.setChecked(false);
<!--布局-->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> <TextView
android:id="@+id/textviewtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="平时喜欢做什么事情?" /> <CheckBox
android:id="@+id/checkboxall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textviewtitle"
android:layout_alignTop="@id/textviewtitle"
android:layout_toRightOf="@id/textviewtitle"
android:text="全选" />
<!--内容的CheckBox-->
<CheckBox
android:id="@+id/checkbox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textviewtitle"
android:layout_marginRight="80dp"
android:text="玩游戏" /> <CheckBox
android:id="@+id/checkbox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textviewtitle"
android:layout_toRightOf="@+id/checkbox1"
android:text="学习" /> <CheckBox
android:id="@+id/checkbox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox1"
android:text="敲代码" /> <CheckBox
android:id="@+id/checkbox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox2"
android:layout_toRightOf="@+id/checkbox1"
android:text="跑步" /> <CheckBox
android:id="@+id/checkbox5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox3"
android:text="游泳" /> <CheckBox
android:id="@+id/checkbox6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox4"
android:layout_toRightOf="@+id/checkbox1"
android:text="睡觉" /> <TextView
android:id="@+id/textviewinfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox5"
android:layout_marginTop="20dp"
android:text="已选择:"/>
</RelativeLayout> <!--java代码-->
package com.dc.work3; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast; import java.util.LinkedList;
import java.util.List; /**
* Created by 怪蜀黍 on 2016/11/4.
*/ public class MainActivity2s extends AppCompatActivity {
private CheckBox checkboxall;
private CheckBox checkBox1;
private CheckBox checkBox2;
private CheckBox checkBox3;
private CheckBox checkBox4;
private CheckBox checkBox5;
private CheckBox checkBox6; private TextView textviewinfo;
private List<String> checkedStr; //操作取消一个时,全选取消,这个变量是是否是用户点击
private boolean checkFoUser=true; protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_2); checkboxall = (CheckBox) findViewById(R.id.checkboxall);
checkBox1 = (CheckBox) findViewById(R.id.checkbox1);
checkBox2 = (CheckBox) findViewById(R.id.checkbox2);
checkBox3 = (CheckBox) findViewById(R.id.checkbox3);
checkBox4 = (CheckBox) findViewById(R.id.checkbox4);
checkBox5 = (CheckBox) findViewById(R.id.checkbox5);
checkBox6 = (CheckBox) findViewById(R.id.checkbox6);
textviewinfo = (TextView) findViewById(R.id.textviewinfo); checkBox1.setOnCheckedChangeListener(changeListener);
checkBox2.setOnCheckedChangeListener(changeListener);
checkBox3.setOnCheckedChangeListener(changeListener);
checkBox4.setOnCheckedChangeListener(changeListener);
checkBox5.setOnCheckedChangeListener(changeListener);
checkBox6.setOnCheckedChangeListener(changeListener);
checkboxall.setOnCheckedChangeListener(changeListener); checkedStr=new LinkedList<>(); }
public CompoundButton.OnCheckedChangeListener changeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()){
case R.id.checkbox1:
case R.id.checkbox2:
case R.id.checkbox3:
case R.id.checkbox4:
case R.id.checkbox5:
case R.id.checkbox6:
String str=buttonView.getText().toString();
if(isChecked){
checkedStr.add(str);
}else {
checkedStr.remove(str);
}
checkboxall.setOnCheckedChangeListener(null);
if(checkBox1.isChecked()&&checkBox2.isChecked()&&checkBox3.isChecked()&&checkBox4.isChecked()&&checkBox5.isChecked()&&checkBox6.isChecked()){
//表示如果都选中时,把全选按钮也选中
checkboxall.setChecked(true);
}else {
//否则就全选按钮去不选中,但是这样会触发checkboxall的监听,会把所有的都取消掉
checkboxall.setChecked(false);
}
checkboxall.setOnCheckedChangeListener(changeListener);
break;
case R.id.checkboxall:
if(checkFoUser) {
checkBox1.setChecked(isChecked);
checkBox2.setChecked(isChecked);
checkBox3.setChecked(isChecked);
checkBox4.setChecked(isChecked);
checkBox5.setChecked(isChecked);
checkBox6.setChecked(isChecked);
break;
}
}
StringBuffer sb=new StringBuffer();
for(String str:checkedStr){
sb.append(str+",");
}
if(sb.length()>0){
//设置长度为长度-1,去除最后的“,”
sb.setLength(sb.length()-1);
}
textviewinfo.setText("已选择:"+sb.toString());
}
}; }
 
六、RadioButtonRadioGroup——单选按钮、单选组
RadioButton——单选按钮,继承自TextView
单独使用和CheckBox一样,经常和RadioGroup一起使用,形
成单选效果
RadioGroup——单选组,继承自LinearLayout
常用属性:LinearLayout的属性
常用方法
setOnCheckedChangeLinsener()  内部单选按钮选中改变监听
check()  选中指定id的子项
getCheckedRadioButtonId()  获取选中的RadioButton的id
clearCheck()  清除选中
七、ImageView——图片控件
常用属性
src     指定要显示的图片
adjustViewBounds   控件的大小仅仅显示到图片的范围大小
maxHeight    最大高度
maxWidth    最大宽度
scaleType  缩放类型
nfitStart(等比例自适应大小在开头的显示)  fitEnd(等比例自适应大小在末尾显示)
nfitXY(自适应控件xy大小)  fitCenter(等比例自适应大小在中间显示)
ncenter(按原图片大小在中心显示)  centerCrop(等比例缩放至充满控件)
ncenterInside(图片小于控件宽高时,缩放显示在中间,否则等比例缩放后显示在中间) 
nmatrix(图片不缩放,显示在左上角,此时可以通过setImageMatrix()方法对图片进行操作)
例:
<!--默认缩放:自适应
android:scaleType="fitCenter"-->
<!--center不缩放,显示在中心-->
<!--如果是小图片,不进行缩放,会在中心显示
,如果是大的图片,会进行缩放android:scaleType="centerInside"-->
<!--按照左上角对齐,android:scaleType="matrix"-->
<!--如果要想不管图片多大,都不让其显示边框
android:adjustViewBounds="true"-->
ImageView
android:id="@+id/iv"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:adjustViewBounds="true"
android:background="#ddd"
常用方法
常用方法
setImageResource()  设置显示的图片资源
setImageBitmap()  设置显示的图片位图
setImageDrawable()  设置显示的图片Drawable
setScaleType()  设置缩放类型
具体代码:
iv// 设置图片
ic_launcher//设置缩放类型
CENTER
八、Spinner——下拉列表控件
常用属性
spinnerMode     下拉列表模式
entries    数据实体
如右图,这个是自定义的布局,具体方法:
1.在layout文件夹下创建一个新的文件layout_list_item.xml
该文件中的内容:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
 
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/textview"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
</LinearLayout>
该段代码实现的具体布局,如右图:
 
常用方法:
setAdapter()  设置数据适配器
setOnItemSelectedListener()  设置当子项选中的监听
getSelectedItem()  获取选中项
getSelectedItemId()  获取选中项id
getSelectedItemPosition()  获取选中项的下标
getSelectedView()  获取选中项视图
 
接下来是ActivityArrayadapter.class中的文件代码:
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_arrayadapter);
spinner = (Spinner) findViewById(R.id.spinner);
auto=(AutoCompleteTextView)findViewById(R.id.auto);
//调用android的布局
//如果不使用系统的布局,可以自定义布局
//系统布局
// ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,                   自定义布局
android.R.id.text1, new String[]{"aaabbb", "aabb",
"abfaa", "abcaa", "aaacccc"});
//使用自己的布局,这个布局中,选项的前边会有图片显示
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,
R.layout.layout_list_item,R.id.textview,
new String[]{"aaa", "aaa", "aaa", "aaa"});
spinner.setAdapter(adapter);
auto.setAdapter(adapter);
//这些是解决如果下边提示没有时,上边的会没有显示
spinner.setOnItemSelectedListener(itemSelectedLis);
                      系统布局
}
九、ArrayAdapter——数据适配器
在进行数据显示的时候,经常有大量重复的格式的数据要显示,此时若是一个一个的设置数据会非常麻烦,适配器就是将这样重复的格式的数据自动进行数据的设置的工具
上面的ActivityArrayadapter.class中的文件代码就用到了适配器,请参考:
用法:
ArrayAdapter<String> adapter = new
ArrayAdapter<String>context,layoutRes,textviewId,data);
 
context:上下文  layoutRes:布局资源 
textviewId:textview控件的id data:数据
在需要适配数据的控件调用其setAdapter()方法设置数据
十、 AutoCompleteTextView——建议提示输入框
 
常用属性:
completionHint   设置出现在下拉菜单中的提示标题
completionThreshold   设置用户至少输入多少个字符才会显示提示
dropDownHeight   下拉菜单的高度
dropDownWidth   下拉菜单的宽度
<!--建议提示输入框-->
<AutoCompleteTextView
android:id="@+id/auto"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
 
常用方法:
EditText的方法
setAdapter()  设置数据适配器
auto=(AutoCompleteTextView)findViewById(R.id.auto);
auto.setAdapter(adapter);
 
十一、滚动条的基本使用
Ⅰ:ScrollView——竖向滚动条
Ⅱ:HorizontalScrollView——横向滚动条
常用属性:
scrollbars    滚动条
Horizontal:横向滚动条  vertical:竖向滚动条  none  :无滚动条
注意:滚动条里有且只能有一个子控件
<!--注意,ScrolView只能有一个子控件,要想有多个空间,使用Linear Layout包裹-->
例:
<!--虽然高度是充满,但是他是包裹的-->
<!--android:scrollbars="none"无滚动条-->
<!--android:overScrollMode="never" 滚动条到头的提示模式-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:overScrollMode="never">
十二、ProgressBar——进度条
常用属性:
style  设置进度条样式
max  设置进度条最大值
progress  设置进度条进度值
secondaryProgress  第二进度条
maxHeight/maxWidth  最大宽高
minHeight/minWidth  最小宽高
progressDrawable  设置进度条图片
 
<!--android:indeterminate="true" 设置进度条不确定值的进度条-->
<!--android:progressDrawable="@drawable/progress_bar_drawable"
我们自定义的进度条-->
<!--高度最大最小android:maxHeight="2dp"
 
android:minHeight="2dp"-->
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="4"
android:secondaryProgress="6"
android:progressDrawable="@drawable/progress_bar_drawable"
/>
<!--自定义布局-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--注意顺序不能改变,先写的在最下边显示-->
<!--这一项我们修改背景-->
<item android:id="@android:id/background" android:drawable="@mipmap/a"/>
<!--这一项我们修改第二进度-->
<item android:id="@android:id/secondaryProgress" android:drawable="@mipmap/b"/>
<!--这一项我们修改进度-->
<item android:id="@android:id/progress" android:drawable="@mipmap/c"/>
</layer-list>
常用方法:
setMax()  设置最大值
setProgress()  设置进度值
getProgress()  获取进度值
setSecondaryProgress()  设置第二进度值
getSecondaryProgress()  获取第二进度值
可以实现点击按钮,增加进度和减少进度,包括下边有些内容
都在这代码中:

<!--布局-->

<?xml version="1.0" encoding="utf-8"?>
<!--虽然高度是充满,但是他是包裹的-->
<!--android:scrollbars="none"无滚动条-->
<!--android:overScrollMode="never" 滚动条到头的提示模式-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:overScrollMode="never"> <!--注意,ScrolView只能有一个子控件,要想有多个空间,使用Linear Layout包裹-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--横向滚动条-->
<!--因为是横向滚动条,所以不管你宽度设置多少,他始终是充满的-->
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"></HorizontalScrollView> <!--进度条-->
<!--android:indeterminate="true" 设置进度条不确定值的进度条-->
<!--android:progressDrawable="@drawable/progress_bar_drawable"我们自定义的进度条-->
<!--高度
android:maxHeight="2dp"
android:minHeight="2dp"-->
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="4"
android:secondaryProgress="6"
android:progressDrawable="@drawable/progress_bar_drawable"
/> <!--可以拖拽的进度条-->
<!-- android:thumb="@mipmap/ic_launcher"自定义图片-->
<!-- android:thumbOffset="100dp" 偏移量,一般不会用到-->
<!--android:thumbTint="#0ff" 着色,不管什么图片还是默认,颜色都改变-->
<!--鼠标悬浮上边这句话时,他的意思是,21版本才可以使用,当前版本是16-->
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumb="@mipmap/ic_launcher"
android:thumbTint="#0ff"
android:progress="50"/> <!-- android:visibility="invisible" 默认隐藏-->
<!--调整文本框的大小尽量使用边来改变-->
<TextView
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:background="#cdcdcd"
android:text="0%"
android:textSize="22sp"
android:visibility="invisible"
android:layout_gravity="center_horizontal"/> <!--注意使用时,宽度和高度都使用包裹-->
<!--android:stepSize="1"每次增长1-->
<!--android:isIndicator="true" 是否作为指示器,比如QQ等级-->
<!--style="?android:attr/ratingBarStyleSmall"-->
<!--hdpi是mdpi的1.5倍,xmdpi是m的2倍-->
<RatingBar android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="1.5"
android:stepSize="0.5"
android:progressDrawable="@drawable/rating_bar_drawable"
android:minHeight="21dp"
android:maxHeight="21dp"/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="减少"/> <Button
android:id="@+id/bt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="增加"/>
</LinearLayout> <!--为了看清楚效果,这里我们把高度设为20dp,text设置多点字符,这样就超出了屏幕-->
<TextView
android:layout_width="20dp"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
具体功能实现的java代码 package com.dc.work3; import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.Spinner; /**
* Created by 怪蜀黍 on 2016/11/4.
*/ public class MainActivity_radiobutton extends AppCompatActivity {
private RadioGroup rg; private Spinner spinner; //重写一个参数的处事方法
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_radiobutton); rg= (RadioGroup) findViewById(R.id.rg1);
rg.setOnCheckedChangeListener(changeLis);
//如果没有任何选中项,返回-1
// rg.getCheckedRadioButtonId();
//选中指定项
// rg.check(R.id.rb1);
//清除选中项
// rg.clearCheck(); ImageView img=(ImageView) findViewById(R.id.iv);
// 设置图片
img.setImageResource(R.mipmap.ic_launcher);
//设置缩放类型
img.setScaleType(ImageView.ScaleType.CENTER); spinner=(Spinner)findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(itemSelectedListener); }
private AdapterView.OnItemSelectedListener itemSelectedListener =new AdapterView.OnItemSelectedListener() {
@Override//当项选中时 参数1:触发事件的控件 2:选中的视图 3:选中视图的id
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { }
@Override//当没有项选中时
public void onNothingSelected(AdapterView<?> parent) { }
}; private RadioGroup.OnCheckedChangeListener changeLis=new RadioGroup.OnCheckedChangeListener() {
@Override //参数2:选中者的id
public void onCheckedChanged(RadioGroup group, int checkedId) {
//获取选中项的数据
String str=spinner.getSelectedItem().toString();
//获取选中项的下标
int position=spinner.getSelectedItemPosition();
//获取选中项的id
long id= spinner.getSelectedItemId();
Log.e("aaaa",str+"========="+position+"========="+id);
}
};
}
 
十三、SeekBar——拖动条
常用属性:
max  最大值
progress  进度值
secondaryProgress  第二进度条
progressDrawable  进度图片
thumb  拖拽按钮
thumbOffset  拖拽按钮位置补偿
maxHeight/maxWidth    最大宽高
minHeight/minWidth  最小宽高
 
例:
<!--可以拖拽的进度条-->
 
<!-- android:thumb="@mipmap/ic_launcher"自定义图片-->
<!-- android:thumbOffset="100dp" 偏移量,一般不会用到-->
<!--android:thumbTint="#0ff" 着色,不管什么图片还是默认,颜色都改变-->
<!--鼠标悬浮上边这句话时,他的意思是,21版本才可以使用,当前版本是16-->
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumb="@mipmap/ic_launcher"
android:thumbTint="#0ff"
android:progress="50"/>
常用方法:
setProgress()  设置进度值
getProgress()  获取进度值
setSecondaryProgress()  设置第二进度值
getSecondaryProgress()  获取第二进度值
setSeekBarChangeListener()  设置seekbar拖动改变监听
具体代码:在上一个代码中
 
十四、RatingBar——等级条
常用方法:
numStars  最大值
rating  等级值
stepSize  最小步进值
progressDrawable  进度图片
isIndicator  是否是指示器
例:
<!--注意使用时,宽度和高度都使用包裹-->
<!--android:stepSize="1"每次增长1-->
<!--android:isIndicator="true" 是否作为指示器,比如QQ等级-->
<!--style="?android:attr/ratingBarStyleSmall"-->
<!--hdpi是mdpi的1.5倍,xmdpi是m的2倍-->
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="1.5"
android:stepSize="0.5"
android:progressDrawable="@drawable/rating_bar_drawable"
android:minHeight="21dp"
android:maxHeight="21dp"/>
 
自定义的布局
<!--注意:顺序不可以改变,先写的在最下一层-->
<!--背景-->
<!--第二进度-->
<!--进度-->
<item
android:id="@android:id/background"
android:drawable="@mipmap/favour_icon"/>
<item
android:id="@android:id/secondaryProgress"
android:drawable="@mipmap/favour_icon"/>
<item
android:id="@android:id/progress"
android:drawable="@mipmap/favoured_icon"/>

Android表单UI及相应控件的事件处理的更多相关文章

  1. Bootstrap3 表单-被支持的控件:文本域

    支持多行文本的表单控件.可根据需要改变 rows 属性. <textarea class="form-control" rows="3"></ ...

  2. Bootstrap3 表单-被支持的控件:输入框

    输入框包括大部分表单控件.文本输入域控件,还支持所有 HTML5 类型的输入控件: text.password.datetime.datetime-local.date.month.time.week ...

  3. html表单的各种输入控件

    表单的输入控件主要是input和select.其中input可以是多种类型,通过type属性来进行定义,type可以取值是text,radio,checkbox,password,submit,res ...

  4. BarTender 2016表单中的“秤显示”控件

    BarTender 2016中的表单是一个非常实用的工具,它可以实现数据输出提示,查询提示和同一表单的记录选择.这些都离开可供添加的控件,“秤显示”控件也是我们打印尝尝需要涉及的,今天我们就来看看什么 ...

  5. Appium Android Bootstrap源码分析之控件AndroidElement

    通过上一篇文章<Appium Android Bootstrap源码分析之简介>我们对bootstrap的定义以及其在appium和uiautomator处于一个什么样的位置有了一个初步的 ...

  6. iOS开发UI篇—UIScrollView控件介绍

    iOS开发UI篇—UIScrollView控件介绍 一.知识点简单介绍 1.UIScrollView控件是什么? (1)移动设备的屏幕⼤大⼩小是极其有限的,因此直接展⽰示在⽤用户眼前的内容也相当有限 ...

  7. Android support library支持包常用控件介绍(二)

    谷歌官方推出Material Design 设计理念已经有段时间了,为支持更方便的实现 Material Design设计效果,官方给出了Android support design library ...

  8. Android开发技巧——自定义控件之组合控件

    Android开发技巧--自定义控件之组合控件 我准备在接下来一段时间,写一系列有关Android自定义控件的博客,包括如何进行各种自定义,并分享一下我所知道的其中的技巧,注意点等. 还是那句老话,尽 ...

  9. (转载) Android 带清除功能的输入框控件ClearEditText,仿IOS的输入框

    Android 带清除功能的输入框控件ClearEditText,仿IOS的输入框 标签: Android清除功能EditText仿IOS的输入框 2013-09-04 17:33 70865人阅读  ...

随机推荐

  1. ExtJs TreePanel 使用帮助

    tree :树 node:节点 1.全部展开 tree.expandAll(); 2.全部收缩 tree.collapseAll(); 3.得到父节点 node.parentNode 4.判断是否有父 ...

  2. 超实用的8个Linux命令行性能监测工具

    http://www.csdn.net/article/2012-09-17/2810047-command-line-tools-to-monitor-linux-perf 你值得拥有:25个Lin ...

  3. 【WPF】控件使用-宽度自动适应窗口大小

    <Grid MinWidth="1260" HorizontalAlignment="Stretch" />

  4. Love

    愿这段代码陪我走过此生,献给我最爱的榨菜. /** *@Description:<p>我爱榨菜</p> *@author 王旭 *@time 2016年4月25日 下午7:58 ...

  5. [前端]npm安装慢,换用淘宝的镜像

    镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 通过config命令 npm config set registry https://registry ...

  6. android基础---->JSON数据的解析

    上篇博客,我们谈到了XML两种常用的解析技术,详细可以参见我的博客(android基础---->XMl数据的解析).网络传输另外一种数据格式JSON就是我们今天要讲的,它是比XML体积更小的数据 ...

  7. mysql如何更改数据库名(一键实现mysql改数据库名)

    由于某种原因,有时我们有可能需要数据库的名称,但是不像官方有rename可以去更改表名,并没有一个命令可以去更新数据库的名字. 思路:借助rename这个命令 基本操作:rename olddb.ta ...

  8. js用正则表达式验证用户和密码的安全性,生成随机验证码

    制作了一个表单,表单验证用户.密码.随机验证码 html页面

  9. [moka同学笔记]yii2.0导航栏

    导航栏 <?php use yii\helpers\Url; /** * $navbar说明 * label:显示的标签 * url:跳转地址 * action:判断激活的操作 * class: ...

  10. isEmpty与null、""的区别

    前一段时间我阅读别人的代码,发现有的时候用isEmpty,有的时候用null,有的时候用"".我很困惑三者之间的区别,于是我就自己写了一个程序来验证一下 public class ...