0

テキスト項目のリストビューがありますが、リストビューの不透明度(アルファ)を減らしたいです。アルファを設定すると、テキストとレイアウトの色の両方を減らしますが、私の要件はリストビューの背景色のみを減らすことです..たとえば、ここに私のコードがあります....

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

1 に答える 1

0

このように実行時にアルファを設定できます

アルファ値 0 ~ 255。0 は完全に透明であることを意味し、255 は完全に不透明であることを意味します。

View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
于 2013-03-06T05:21:15.563 に答える