ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)
1.ProgressBar(进度条)
(1)介绍

(2)常用属性

(3)xml代码
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:max="100"
android:progress="90" />
2.Seeker(拖动条)
(1)介绍

(2)属性介绍

(3)xml布局文件
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/img1" /> <SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
3.RatingBar(星级评分条)
(1)介绍

(2)属性

(3)xml布局
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="店铺评分" /> <RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5" /> <Button
android:id="@+id/button"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提交" />
4.java后台
package com.lucky.test24; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.SeekBar;
import android.widget.Toast; public class MainActivity extends AppCompatActivity { ImageView imageView;
SeekBar seekBar;
ProgressBar progressBar;
EditText editText;
RatingBar ratingBar;
Button button; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView=findViewById(R.id.imageView);
seekBar=findViewById(R.id.seekBar);
progressBar=findViewById(R.id.progressBar2);
editText=findViewById(R.id.editText);
ratingBar=findViewById(R.id.ratingBar);
button=findViewById(R.id.button); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
//状态发生改变时,触发的方法
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progressBar.setProgress(progress); //设置进度条的进度
imageView.setAlpha(progress); //设置图片的亮度
} //刚开始拖动时触发的方法
@Override
public void onStartTrackingTouch(SeekBar seekBar) { } //拖动结束后触发的方法
@Override
public void onStopTrackingTouch(SeekBar seekBar) { }
}); button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str1="";
String str2="";
str1=str1+ratingBar.getRating(); //获取用户评分
str2="您的评价为:"+editText.getText().toString()+"\n您的评分为:"+str1;
Toast.makeText(MainActivity.this,str2,Toast.LENGTH_SHORT).show();
}
});
}
}
5.效果图

ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)的更多相关文章
- Android基础控件RatingBar星级评分条的使用
1.简介 RatingBar继承ProgressBar,除了ProgressBar的属性外还有特有属性: android:isIndicator:是否用作指示,用户无法更改,默认false andro ...
- Android中点击按钮获取星级评分条的评分
场景 效果 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 将布局改为Lin ...
- Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar
原文:Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar 前面两期都在学习ProgressBar的使用,关于自定义ProgressBar的内容后期会继续学习的,本期先 ...
- 星级评分进度条(RatingBar)
星级评分进度条(RatingBar):(主要用于评价等方面) 常用的xml属性; android:isIndicator:RatingBar是否是一个指示器(用户无法进行更改) android:num ...
- 二、Android应用的界面编程(六)ProgressBar及其子类[SeekBar、RatingBar]er
通常用于向用户显示某个耗时操作完成的百分比.Android支持几种风格的进度条,通过style属性可以为ProgressBar指定风格.该属性支持如下几个属性值. # @android:style/W ...
- Android 自学之星级评分条RatingBar
星级评分条(RatingBar)与拖动条十分相似,他们还有共同的父类AbsSeekBar.实际上星级评分条和拖动条的用法和功能都十分的接近:他们都允许用户通过拖动来改变进度.RatingBar与See ...
- Android View 之进度条+拖动条+星级评论条....
PS:将来的你会感谢现在奋斗的自己.... 学习内容: 1.进度条 2.拖动条 3.星级评论条 1.进度条... 进图条这东西想必大家是很熟悉的...为了使用户不会觉得应用程序死掉了,因此 ...
- android中SeekBar拖动进度条的使用及事件监听
下面和大家分享一下android中SeekBar拖动进度条的使用,以及事件监听.拖动进度条的事件监听需要实现SeekBar.OnSeekBarChangeListener接口,调用SeekBar的se ...
- Android 拖动条/滑动条控件、星级评分控件
ProgressBar有2个子控件: SeekBar 拖动条控件 RatingBar 星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...
随机推荐
- AC自动机详解
概述 AC自动机全称Aho-Corasick automaton,该算法在1975年产生于贝尔实验室,是著名的多模匹配算法. 考虑这样一个场景,给出L个模式字符串(加总长度为N),以及长度为M大文本, ...
- 八数码问题——A*大法好
[描述] 在3×3的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字.棋盘中留有一个空格,空格用0来表示. 空格周围的棋子可以移到空格中. 要求解的问题是:给出一种初始布局(初始状态)和目标布局( ...
- 557. Reverse Words in a String III 翻转句子中的每一个单词
[抄题]: Given a string, you need to reverse the order of characters in each word within a sentence whi ...
- CentOS集群自动同步时间的一种方法
CentOS集群自动同步时间的一种方法 之前有篇日志是手动同步时间的 http://www.ahlinux.com/os/201304/202456.html 之所以这么干,是因为我们实验室的局域网只 ...
- 面向对象property属性、静态方法和类方法
一.property属性 1.什么是property特性? property是一种特殊的属性,访问它时会执行一段功能(函数)然后返回值. from math import pi class Circl ...
- 僵固式思维 OR 成长式思维
有意无意中,看到这样的一篇文章,觉得非常富有正能量,而且也比较有同感.而且,不仅仅对于职场暂时失落或者失意的人有帮助,就是对学生,也一样的.故特分享,以共勉之. 我想每个新人进入职场之后都会遇到的第一 ...
- 实践作业3:白盒测试---细化明确任务DAY5
收到老师给我写的评论,感觉老师真的太认真,每个博客都有仔细的,参考了老师发给我的博客,我才明白老师想要的博客内容原来是具体实际的进展记录.我们组其实这些东西早就确定了,会议也开了,但是我之前不明白博客 ...
- SVN下载地址及注意事项
SVN下载地址:VisualSVN:http://www.visualsvn.com/server/download 服务器端(添加仓库和用户)TortoiseSVN:http://torto ...
- 时间日期控件的处理-Selenium
很多人问时间日期的空间怎么处理,但是时间日期控件各种各样,你可能遇到正常点的像这样: 当然也可能遇到难点的,像这样: 当然,也不排除会遇到变态的,像这样: 呵呵,真要一个个想着怎么去选择,简直是非人类 ...
- c# enum遍历
public enum Suit { Spades, Hearts, Clubs, Diamonds } //遍历valueforeach (Suit suit in (Suit[]) Enum.Ge ...