1.activity_main
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.example.music.CustomSeekBarItem android:id="@+id/custom_seek_bar_item" android:layout_width="600dp" android:layout_height="80dp" android:layout_gravity="left" app:is_show_right_text="true" app:right_text="88" app:right_text_color="#fff" /> </LinearLayout>
2.values/attrs
<?xml version="1.0" encoding="utf-8"?> <resources> <!--设置界面的item属性 左边图标 右边文字--> <declare-styleable name="CustomSeekBarItem"> <attr name="left_icon" selectOne="dimension"/> <attr name="is_show_right_text" selectOne="boolean" /> <attr name="right_text" selectOne="string" /> <attr name="right_text_color" selectOne="color" /> </declare-styleable> </resources>
3.新建layout文件activity_custom_seek_bar_item
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/seekbar_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 拖动条 --> <SeekBar android:id="@+id/seek_bar" android:layout_width="match_parent" android:layout_height="match_parent" android:backgr标签:layout,进度条,custom,简易,values,精美,activity,seek From: https://blog.csdn.net/y2331896617/article/details/141500597