Android 半透明搜索杆

Android 半透明搜索杆,android,transparency,seekbar,Android,Transparency,Seekbar,我更希望我的应用程序中的seekbar看起来是半透明的,这可能吗 <SeekBar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/seekBar1" android:layout_width="match_parent" android:layout_height="wrap_content

我更希望我的应用程序中的seekbar看起来是半透明的,这可能吗

<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>

在XML中,添加以下属性:

android:alpha = "floatValue"
或者,在java代码中使用

setAlpha(floatValue)
它使您能够更改视图的alpha属性

0=完全透明

1=完全不透明


因此,对于半透明,可以根据所需的透明度设置为0.5或任何值

在XML中,添加以下属性:

android:alpha = "floatValue"
或者,在java代码中使用

setAlpha(floatValue)
它使您能够更改视图的alpha属性

0=完全透明

1=完全不透明


因此,对于半透明,可以根据所需的透明度设置为0.5或任何值

android:progressDrawable
属性设置为带有半透明组件的自定义
图层列表。您还可以设置
android:thumb
属性

下面是一个示例可绘制xml,您也可以参考该项目以获取示例图像资产:

<?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>

另外,有关问题:


android:progressDrawable
属性设置为带有半透明组件的自定义
图层列表。您还可以设置
android:thumb
属性

下面是一个示例可绘制xml,您也可以参考该项目以获取示例图像资产:

<?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>

另外,有关问题:


您可以使用十六进制颜色设置不透明度值。您只需要添加正确的前缀。 我使用以下代码隐藏了seekBar:

android:progressBackgroundTint="#00555555"
android:progressTint="#00555555"
其中前两个密码(即“00”)设置不透明性(α百分比),其他六个密码(即“555555”)设置颜色

有关更多信息和十六进制不透明度值列表,请查看此帖子:

您可以使用十六进制颜色设置不透明度值。您只需要添加正确的前缀。 我使用以下代码隐藏了seekBar:

android:progressBackgroundTint="#00555555"
android:progressTint="#00555555"
其中前两个密码(即“00”)设置不透明性(α百分比),其他六个密码(即“555555”)设置颜色

有关更多信息和十六进制不透明度值列表,请查看此帖子:

什么是<代码>进展>黑暗
?什么是<代码>进展>黑暗