SeekBar Seekbar中的一些細節要點

2022-06-11 08:33:34 字數 2954 閱讀 2972

1. 修改seekbar中進度條的高度

android:maxheight和android:minheight 。前者是用來指定進度條最大高度的(此高度並非seekbar整個控制項的高度),後者是用來指定最小高度,一般將這兩個屬性值設定成一致即可。

2. 滑塊和背景之間有截斷的問題

android:thumboffset。通常設定thumb後,滑動會被隱藏一部分。設定thumboffset就可以解決該問題:android:thumboffset="0dp", 該現象在5.0上居多。

3. 滑塊四周不透明

android:splittrack="false"。有時候發現ui給的滑塊四周是透明的,但是放上去之後發現四周是不透明的,這是因為「the material seek bar has split track enabled by default」。

4. 預設seekbar左右兩邊有一定距離的padding

android:paddingstart="0dp"

android:paddingleft="0dp"

android:paddingend="0dp"

android:paddingright="0dp"

在xml檔案裡將其padding都設定為0。

5. 預設拖拽滑塊時四周會出現陰影

android:duplicateparentstate="true"。若不需要該效果,可指定該屬性。

附:自定義seekbar完整定義:

進度條

xml version="1.0" encoding="utf-8"

?>

<

layer-list

xmlns:android

="">

<

item

android:id

="@android:id/background"

>

<

shape

android:shape

="rectangle"

>

<

solid

android:color

="#acacac"

/>

<

corners

android:radius

="2dp"

/>

shape

>

item

>

<

item

android:id

="@android:id/progress"

>

<

clip

>

<

shape

android:shape

="rectangle"

>

<

solid

android:color

="#2382f7"

/>

<

corners

android:radius

="2dp"

/>

shape

>

clip

>

item

>

layer-list

>

滑塊

xml version="1.0" encoding="utf-8"

?>

<

shape

xmlns:android

=""android:shape

="oval"

>

<

solid

android:color

="#ffffff"

/>

<

stroke

android:width

="1dp"

android:color

="#bbbbbb"

/>

<

size

android:width

="26dp"

android:height

="26dp"

/>

shape

>

xml:

<

seekbar

android:layout_width

="match_parent"

android:layout_height

="wrap_content"

android:layout_marginstart

="20dp"

android:layout_margintop

="20dp"

android:layout_marginend

="20dp"

android:max

="100"

android:maxheight

="2dp"

android:minheight

="2dp"

android:progress

="0"

android:progressdrawable

android:thumb

android:progress

="40"

/>

效果:

1. android 仿vivo的seekbar樣式

2. android seekbar 踩坑之路

linux中 中括號 中的判斷引數

源自 http www.diybl.com course 6 system linux linuxjs 20081117 151774.html b file 若檔案存在且是乙個塊特殊檔案,則為真 c file 若檔案存在且是乙個字元特殊檔案,則為真 d file 若檔案存在且是乙個目錄,則為真 e...

從HIVE中中查詢

從hive資料庫查詢文件 by ymd 拼接sql語句 string sql select from doc file where contains name wildcard 拼接名稱查詢語句 if stringutils.isnoneempty unstructuredbean.getname ...

Spring中classpath中萬用字元號的使用

說明 無萬用字元,必須完全匹配 classpath user base beans.xml 說明 匹配零個或多個字串 只針對名稱,不匹配目錄分隔符等 例如 user a base beans.xml user b base beans.xml 但是不匹配 user base beans.xml cl...