我在FrameLayout中使用谷歌地圖片段進行佈局。另外,我用漸變背景將新視圖放在地圖上。 佈局:透明漸變問題
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<View
android:id="@+id/fadeTop"
android:layout_width="match_parent"
android:layout_height="@dimen/fade_height"
android:layout_gravity="top"
android:background="@drawable/list_fade_top"/>
<include layout="@layout/top_line_mid_gray"/>
</FrameLayout>
list_fade_top:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="@color/fade_start_color"
android:centerColor="@color/fade_center_color"
android:endColor="@color/fade_end_color"
android:type="linear"/>
</shape>
- 開始/結束和中心色。該梯度繪製與光2行:
<color name="fade_start_color">#00000000</color> <color name="fade_center_color">#4f000000</color> <color name="fade_end_color">#ff000000</color>
- 開始/結束和中心色。該梯度繪製用1光線路:
相同的行爲對於梯度而不中心色:
<gradient android:angle="90" android:startColor="@color/fade_start_color" android:endColor="@color/fade_end_color" android:type="linear"/>
<color name="fade_start_color">#00000000</color> <color name="fade_center_color">#6f000000</color> <color name="fade_end_color">#ff000000</color>
how ca ñ我畫一個從黑色(或半透明黑色)到全透明的平滑線性漸變?我嘗試了開啓/關閉硬件加速,'getWindow()。setFormat(PixelFormat.RGBA_8888);'沒有任何幫助我。
更新1 我在github上創建了一個簡單的應用程序。 https://github.com/ralexey/TestApp 只是一個具有彩色背景和漸變的活動。
感謝您的回答,但它並沒有幫助我。 –