Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何降低android中自定义listview的不透明度_Android - Fatal编程技术网

如何降低android中自定义listview的不透明度

如何降低android中自定义listview的不透明度,android,Android,我有一个文本项的列表视图,我想减少列表视图的不透明度(alpha)。当我设置alpha时,然后减少文本和布局颜色,但我的要求是只减少listview的背景颜色。。例如 这是我的密码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_paren

我有一个文本项的列表视图,我想减少列表视图的不透明度(alpha)。当我设置alpha时,然后减少文本和布局颜色,但我的要求是只减少listview的背景颜色。。例如 这是我的密码

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:listSelector="@android:color/transparent"
    android:background="@drawable/bg"
    >
<ScrollView
   android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
   >
<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    >
 <!--  <EditText android:id="@+id/inputSearch"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Search Remedy.."
        android:inputType="textVisiblePassword"/> android:listSelector="@drawable/list_selector"-->
    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#b5b5b5"
        android:dividerHeight="0.5dp"
        android:background="@drawable/list_selector"
         />
 </LinearLayout>
</ScrollView>
</RelativeLayout>

您可以像这样在运行时设置alpha

Alpha值0-255,0表示完全透明,255表示完全不透明

View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);