문제

Seekbar Android 위젯에서 배경 막대 이미지를 제거 할 수있는 방법이 있습니까?

나는 그 뒤에 진행 막대가없는 슬라이더를 보여주기를 원합니다.

Remove this

도움이 있습니까?

도움이 되었습니까?

해결책 2

글쎄, 나는 내 자신의 문제를 해결했다.

배경을 제거하려면 공백 드로우 가능성을 만들어 ProgressDrable로 설정해야합니다.

satBar.setProgressDrawable(invisibleBackground);

널로 설정하는 것은 작동하지 않는 것 같습니다.

다른 팁

새로운 드로우 가능성을 만들 필요가없는 간단한 방법이 있습니다. XML 정의에서 다음을 설정하기 만하면됩니다

android:progressDrawable="@android:color/transparent"

또는 코드에서 수행하려면 :

mySlider.setProgressDrawable(new ColorDrawable(android.R.color.transparent));

당신은 시도 했습니까? setBackgroundDrawable(null)?

이를 수행하는 한 가지 방법은 진행률 표시 줄의 색상을 배경색으로 변경하는 것입니다. 사용자 정의 레이아웃을 사용해야합니다.

<SeekBar
  android:layout_width="350px"
  android:layout_height="25px"
  android:layout_margin="30px"
  android:layout_x="60px"
  android:layout_y="185px"
  android:id="@+id/seekbar"
  android:progressDrawable="@drawable/myprogress"
/>

맞춤형 레이아웃은 아래에 나와 있습니다 - 색상으로 재생합니다.

<?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="5dip" />
    <gradient
            android:startColor="#ff9d9e9d"
            android:centerColor="#ff5a5d5a"
            android:centerY="0.75"
            android:endColor="#ff747674"
            android:angle="270"
    />
</shape>
</item>


<item
android:id="@android:id/progress"
>
<clip>
    <shape>
        <corners
            android:radius="5dip" />
        <gradient
            android:startColor="#9191FE"
            android:centerColor="#9191FE"
            android:centerY="0.75"
            android:endColor="#9191FE"
            android:angle="270" />
    </shape>
</clip>
</item>

XML 파일을 만듭니다 seekbar_progress.xml 그리고 그것을 넣습니다 drawable 폴더. drawable 폴더.

Seekbar_progress.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >  

  <item>
    <clip>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/stripes"
        android:tileMode="repeat"
        android:antialias="true"
        android:dither="true"
        android:filter="false"
        android:gravity="left"
    />
    </clip>
</item>
</layer-list>

이제 당신의 main xml Seekbar 코드가있는 파일, 이미지를 찍고 drawable Folder.here Seekbar는 이미지입니다.

    <SeekBar
             android:id="@+id/seekbar"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:background="@drawable/seekbar"
             android:progressDrawable="@drawable/seekbar_progress"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top