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

时间:2021-09-06 11:44:02

1.ProgressBar(进度条)

(1)介绍

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

(2)常用属性

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

(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)介绍

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

(2)属性介绍

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

(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)介绍

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

(2)属性

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

(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)

ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)的更多相关文章

  1. Android基础控件RatingBar星级评分条的使用

    1.简介 RatingBar继承ProgressBar,除了ProgressBar的属性外还有特有属性: android:isIndicator:是否用作指示,用户无法更改,默认false andro ...

  2. Android中点击按钮获取星级评分条的评分

    场景 效果 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 将布局改为Lin ...

  3. Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar

    原文:Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar 前面两期都在学习ProgressBar的使用,关于自定义ProgressBar的内容后期会继续学习的,本期先 ...

  4. 星级评分进度条(RatingBar)

    星级评分进度条(RatingBar):(主要用于评价等方面) 常用的xml属性; android:isIndicator:RatingBar是否是一个指示器(用户无法进行更改) android:num ...

  5. 二、Android应用的界面编程(六)ProgressBar及其子类&lbrack;SeekBar、RatingBar&rsqb;er

    通常用于向用户显示某个耗时操作完成的百分比.Android支持几种风格的进度条,通过style属性可以为ProgressBar指定风格.该属性支持如下几个属性值. # @android:style/W ...

  6. Android 自学之星级评分条RatingBar

    星级评分条(RatingBar)与拖动条十分相似,他们还有共同的父类AbsSeekBar.实际上星级评分条和拖动条的用法和功能都十分的接近:他们都允许用户通过拖动来改变进度.RatingBar与See ...

  7. Android View 之进度条&plus;拖动条&plus;星级评论条&period;&period;&period;&period;

    PS:将来的你会感谢现在奋斗的自己.... 学习内容: 1.进度条 2.拖动条 3.星级评论条 1.进度条...       进图条这东西想必大家是很熟悉的...为了使用户不会觉得应用程序死掉了,因此 ...

  8. android中SeekBar拖动进度条的使用及事件监听

    下面和大家分享一下android中SeekBar拖动进度条的使用,以及事件监听.拖动进度条的事件监听需要实现SeekBar.OnSeekBarChangeListener接口,调用SeekBar的se ...

  9. Android 拖动条&sol;滑动条控件、星级评分控件

    ProgressBar有2个子控件: SeekBar   拖动条控件 RatingBar   星级评分控件 1.拖动条控件 <SeekBar android:layout_width=&quot ...

随机推荐

  1. 在DevExpress程序中使用TeeList控件以及节点查询的处理

    在很多情况下,我们需要通过树列表进行数据的展示,如一些有层次关系的数据,通过有层级的展示,能够使用户更加直观查看和管理相关的数据.在一般Winform开发的情况下,可以使用微软的TreeView控件, ...

  2. JS之原型对象

    1.__proto__ 每个对象都有一个__proto__属性,指向该对象的原型对象 <script> var person = function(name,city){ this.nam ...

  3. leetcode&lowbar;401&lowbar;Binary Watch&lowbar;回溯法&lowbar;java实现

    题目: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bot ...

  4. BZOJ2818&colon; Gcd 欧拉函数求前缀和

    给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. 如果两个数的x,y最大公约数是z,那么x/z,y/z一定是互质的 然后找到所有的素数,然后用欧拉函数求一 ...

  5. postgresql 行转列,列转行后加入到一个整体数据

    这里行转列的基本思想就是使用max,因为其他列下面都是NULL,所以可以Max最后就只能得到有值的这行 普通的查询: SELECT icd , case when (ROW_NUMBER() OVER ...

  6. python字符串实战

    haproxy配置文件 思路:读一行,写一行 global log 127.0.0.1 local2 daemon maxconn 256 log 127.0.0.1 local2 info defa ...

  7. linux开机启动smb服务

    修改/etc/rc.local文件(增加红色部分) [root@localhost ~]# cat /etc/rc.local #!/bin/sh## This script will be exec ...

  8. zzuli 2130&colon; hipercijevi 链式前向星&plus;BFS&plus;输入输出外挂

    2130: hipercijevi Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 595  Solved: 112 SubmitStatusWeb B ...

  9. Jmeter&lpar;三&rpar;&lowbar;配置元件

    HTTP Cookie Manager 用来存储浏览器产生的用户信息 Clear Cookies each Iteration:每次迭代请求,清空cookies,GUI中定义的任何cookie都不会被 ...

  10. javascript内置对象速查(二)

    Window对象 每个浏览器窗口或框架都对应于一个Window对象,它是随body或frameset元素的每个实例一起创建的对象. function status_text(){ window.sta ...