我有一个文本项列表视图,我希望减少listview的不透明度(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>
答案 0 :(得分:0)
你可以在运行时像这样设置alpha
Alpha值0-255,0表示完全透明,255表示完全不透明
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);