0

I prefer if I could my the seekbar in my app looks Translucent, is this possible?

<SeekBar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/topBar"
            android:layout_marginTop="26dip"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:max="100"
            android:background="@drawable/roundedcorner" >
        </SeekBar>
Swayam
  • 16,294
  • 14
  • 64
  • 102
user836026
  • 10,608
  • 15
  • 73
  • 129

3 Answers3

3

Set the android:progressDrawable attribute to a custom layer-list drawable with translucent components. You can set the android:thumb property as well.

Here's a sample drawable xml from HoloEverywhere, you can reference that project for sample image assets, too:

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

    <item android:id="@android:id/background"
          android:drawable="@drawable/progress_bg_holo_dark" />

    <item android:id="@android:id/secondaryProgress">
        <scale android:scaleWidth="100%"
               android:drawable="@drawable/progress_secondary_holo_dark" />
    </item>

    <item android:id="@android:id/progress">
        <scale android:scaleWidth="100%"
               android:drawable="@drawable/progress_primary_holo_dark" />
    </item>

</layer-list>

Also - related question:

Custom Drawable for ProgressBar/ProgressDialog

Community
  • 1
  • 1
Sam Dozor
  • 40,335
  • 6
  • 42
  • 42
0

In your XML, add this attribute :

android:alpha = "floatValue"

or, in the java code use

setAlpha(floatValue)

It enables you to change the alpha property of the view.

0 = completely transparent

1 = completely opaque

So, for translucent, you can set to 0.5 or any value according to the transparency you desire.

Swayam
  • 16,294
  • 14
  • 64
  • 102
0

You can set opacity value using hex colors. You just need to add the right prefix. I hid the seekBar using this code:

android:progressBackgroundTint="#00555555"
android:progressTint="#00555555"

Where the first two ciphers (i.e. "00") set opaqueness (alpha percentage) and the other six (i.e. "555555") set the color.

Check this post for more information and a list of hex opacity values: Understanding colors on Android (six characters)

Community
  • 1
  • 1
wraithie
  • 343
  • 1
  • 6
  • 19