티스토리 뷰

Android/XML

<SeekBar>

혀가 길지 않은 개발자 2020. 8. 15. 12:58

res/drawable/seek_bar_thumb.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 원모양의 시크바 컨트롤러 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false"  >
    <!-- 배경 -->
    <solid
        android:color="@android:color/white"/>
    <!-- 크기 -->
    <size
        android:width="16dp"
        android:height="16dp"/>
</shape>

seek_bar_thumb.xml

 

 

 

 

 

 

res/drawable/seek_bar_progress.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/background">
        <shape android:shape="line">
            <stroke
                android:width="4dp"
                android:color="@android:color/holo_blue_bright"/>
        </shape>
    </item>

    <item android:id="@+id/secondaryProgress">
        <clip>
            <shape android:shape="line">
                <stroke
                    android:width="4dp"
                    android:color="@android:color/holo_blue_bright"/>
            </shape>
        </clip>
    </item>

    <item android:id="@+id/progress">
        <clip>
            <shape android:shape="line">
                <stroke
                    android:width="4dp"
                    android:color="#FF541F"/>
            </shape>
        </clip>
    </item>

</layer-list>

seek_bar_progress.xml

 

 

 

 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#68000000"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_gravity="bottom"
        android:orientation="horizontal" >

        <SeekBar
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:thumb="@drawable/seek_bar_thumb"
            android:progressDrawable="@drawable/seek_bar_progress"/>

    </LinearLayout>

</FrameLayout>

activity_main.xml

 

실행 결과

 

 

 

 

 

 

'Android > XML' 카테고리의 다른 글

<ConstraintLayout>  (0) 2020.08.23
핸드폰 회전 시 동영상 초기화 방지  (0) 2020.08.17
networkSecurityConfig  (0) 2020.08.14
<EditText>  꾸미기  (0) 2020.08.04
<layer-list>  (0) 2020.08.04
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함