ここのような透明なヘッダーで同様のlistViewを構築しようとしていますが、固定された透明なヘッダーをListViewに添付しますか? しかし、ヘッダーの不透明度を変更するにはどうすればよいですか? 「#00bebebe」のようなカラーコードでアルファを使用しようとしましたが、うまくいきませんでした。
私のヘッダーの背景「title_bar_background」
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Top color -->
<item android:bottom="20dip">
<shape android:shape="rectangle">
<solid android:color="#bebebe"
/>
</shape>
</item>
<!-- Bottom color -->
<item android:top="20dip">
<shape android:shape="rectangle">
<solid android:color="#696969" />
</shape>
</item>
</layer-list>
私のヘッダーレイアウト「custom_title」
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
....
android:background="@drawable/title_bar_background"
android:id="@+id/customLayout"
>
そして、custom_titleを含む私のlistView
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
..... >
<include
layout="@layout/custom_title"
android:layout_height="40dip"
android:layout_width="fill_parent"/>
この作業は不透明度を変更します
View backgroundImg = findViewById(R.id.mycustomLayout);
Drawable background = backgroundImg.getBackground();
background.setAlpha(40);
ただし、そのレイアウトを他のレイアウトに含めない場合にのみ機能します。しかし、そのレイアウトを他のレイアウトに含めるときに、どうすれば不透明度を設定できますか? (上記の私のxmlレイアウトのように)