如何降低android中自定义listview的不透明度
我有一个文本项的列表视图,我想减少列表视图的不透明度(alpha)。当我设置alpha时,然后减少文本和布局颜色,但我的要求是只减少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
<?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);