最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android SeekBar實(shí)現(xiàn)平滑滾動

 更新時(shí)間:2021年03月31日 12:00:32   作者:酥脆  
這篇文章主要為大家詳細(xì)介紹了Android SeekBar實(shí)現(xiàn)平滑滾動,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android SeekBar實(shí)現(xiàn)平滑滾動的具體代碼,供大家參考,具體內(nèi)容如下

由于項(xiàng)目需要,SeekBar只需要三個檔,但是如果只設(shè)置三個檔會很難滑,看著也不好看,于是我將其設(shè)置為100,然后自動滑到0,50,100的位置

大部分代碼還是跟之前一樣,只是把max改為100,progress改為50

<SeekBar
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:max="100"
  android:thumb="@drawable/device_control_yellow_mid_img_40"
  android:maxHeight="8dp"
  android:progress="50"
  android:progressDrawable="@drawable/seek_style"
  android:id="@+id/id_seek_bar"
  android:layout_marginTop="100dp"
 />

然后

public class MainActivity extends Activity implements SeekBar.OnSeekBarChangeListener{

 private int quota;//當(dāng)前滑動到的值


 //我的習(xí)慣,在Activity后面implements點(diǎn)擊事件,然后在類中處理
 @Override
 public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
  quota=i;

 }

 @Override
 public void onStartTrackingTouch(SeekBar seekBar) {
  mTextView.setText("按下SeekBar ");

 }

 @Override
 public void onStopTrackingTouch(SeekBar seekBar) {
  mTextView.setText("松開SeekBar ");
  setSeekBar(quota);
 }

 private void setSeekBar(int i){
  if (i<33){
   mTextView2.setText("低溫");
   Drawable drawable=getResources().getDrawable(R.drawable.green_low_img_40);
   mSeekBar.setThumb(drawable);
   mSeekBar.setProgress(1);
  }else
  if (i>66){
   mTextView2.setText("高溫");
   Drawable drawable2=getResources().getDrawable(R.drawable.red_high_img_40);
   mSeekBar.setThumb(drawable2);
   mSeekBar.setProgress(99);
  }else {
   mTextView2.setText("中溫");
   Drawable drawable1=getResources().getDrawable(R.drawable.yellow_mid_img_40);
   mSeekBar.setThumb(drawable1);
   mSeekBar.setProgress(50);

  }
 }

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

开江县| 蒙自县| 崇义县| 苍溪县| 视频| 杭锦后旗| 即墨市| 宜宾县| 兴义市| 普格县| 雷波县| 延津县| 团风县| 龙海市| 大余县| 阿勒泰市| 平顶山市| 茌平县| 五常市| 宣武区| 洱源县| 溆浦县| 肇州县| 沭阳县| 额尔古纳市| 雷州市| 连城县| 山阴县| 蓬安县| 白沙| 察隅县| 宜黄县| 顺平县| 天气| 汉寿县| 监利县| 黄大仙区| 华容县| 香河县| 高邮市| 汨罗市|