ソリューション#2(ScrollViewの背景プロパティを使用)は、あなたが挙げた1つの問題(背景とフェードの色を異ならせたい場合がある)を乗り越えることができるために機能します。 [Android 1.6ベースの回答] don30-release2
これは、エッジが0x8800FF00にフェードして一般的な背景が違うところです(この場合、0x8800FF00の上に0x88FFFFFFが表示されますアルファは関連している)と子の背景には、(ボタン、黒と白のテキストセクションが不透明で)まだ異なっている:
お知らせレイアウトファイル内の背景設定:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#8800FF00"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#88FFFFFF"
>
<Button android:text="Hello no style" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
...
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:background="@android:color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:textColor="#80ffffff" android:text="#80ffffff" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
...
</LinearLayout>
<LinearLayout
android:background="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:textColor="#80ffffff" android:text="#80ffffff" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
...
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
View.javaがエッジを適用する方法は、最初にScrollViewの背景(ある場合)を描画し、オフスクリーンビットマップ(ContentBitmap)でScrollViewのコンテンツを描画し、DST_OUT xfermodeのLinearGradientをエッジに適用することです。 DST_OUTはソースからのアルファのみを使用し、LinearGradient/DST_OUTはContentBitmapのエッジを徐々に透明と暗にします。 View.draw()は、ContentBitmapをSRC_OVER xfermode経由でメインキャンバスにマージします。これにより、以前に描画された背景が半透明のContentBitmapピクセルで表示されます。 adroid:colorCacheHint
として
ノート
、それはリストビュー(ただしScrollView)は順に、View.ScrollabilityCache.setFadeColor()
を呼び出し、代わりDST_OUTのSRC_OVERのてLinearGradientを作成するView.draw()
を引き起こす、View.getSolidColor()
をオーバーライドするために使用する値です。 1。 setFadeColor()
は、勾配をhintColor|0xFF000000
から0x0
までの範囲に設定します。また、SRC_OVERはContentBitmapの結果ピクセルを既に透明なものにしていないことに注意してください。このように、フェードの単色バリエーションは、実際にはフェードピクセルではなくペイント・フェード・エフェクト・オン・トップです透明である。
View.javaのフェーディングエッジ機能はプライベートです。あなたのサブクラスでそれを再実装することです。
リストア(ListActivityから取得)と同じ背景設定を試しましたが、フェードがバックグラウンドで正しく適用されているようです。別の日のためのパズル。
update: ListViewsのように見えるcacheColorHintは、アルファ値も無視します。 shite。 – Joakim