SeekBar
16lz
2021-01-23
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<SeekBar android:id="@android:id/progress" style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/seekbar_style" android:thumb="@drawable/seek"
android:layout_width="fill_parent" android:layout_height="23dip"
android:paddingLeft="25dip" android:paddingRight="25dip"
android:paddingBottom="4dip" />
</LinearLayout>
styles
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="10dip" />
<gradient android:startColor="#ffffffff"
android:centerColor="#ff000000" android:endColor="#ff808A87"
android:centerY="0.45" android:angle="270" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="10dip" />
<gradient android:startColor="#ffffffff"
android:centerColor="#ffFFFF00" android:endColor="#ffAABD00"
android:centerY="0.45" android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
seek.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--按钮按下状态 -->
<item android:state_pressed="true" android:drawable="@drawable/seek" />
<!-- 普通无焦点状态 -->
<item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/seek" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<SeekBar android:id="@android:id/progress" style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/seekbar_style" android:thumb="@drawable/seek"
android:layout_width="fill_parent" android:layout_height="23dip"
android:paddingLeft="25dip" android:paddingRight="25dip"
android:paddingBottom="4dip" />
</LinearLayout>
styles
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="10dip" />
<gradient android:startColor="#ffffffff"
android:centerColor="#ff000000" android:endColor="#ff808A87"
android:centerY="0.45" android:angle="270" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="10dip" />
<gradient android:startColor="#ffffffff"
android:centerColor="#ffFFFF00" android:endColor="#ffAABD00"
android:centerY="0.45" android:angle="270" />
</shape>
</clip>
</item>
</layer-list>
seek.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--按钮按下状态 -->
<item android:state_pressed="true" android:drawable="@drawable/seek" />
<!-- 普通无焦点状态 -->
<item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/seek" />
</selector>
更多相关文章
- Android 音量增加减少按钮事件
- Android 隐藏系统状态栏和标题栏
- Android对话框的高级设置《二》设置对话框按钮的透明度和对话框
- Android App 隐藏显示标题栏、状态栏、导航栏
- Android中的集中常用布局方式和按钮事件的处理方式
- Android 蓝牙状态机以及蓝牙启动状态机
- Android中获取屏幕相关信息(屏幕大小,状态栏、标题栏高度)
- 获取Android设备电池电量状态
- Android 5.1系统禁止通知状态栏下拉