I have layout with google map fragment in FrameLayout. Also, i placed the new view over the map with gradient background. Layout:
<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>
<color name="fade_start_color">#00000000</color>
<color name="fade_center_color">#4f000000</color>
<color name="fade_end_color">#ff000000</color>
<color name="fade_start_color">#00000000</color>
<color name="fade_center_color">#6f000000</color>
<color name="fade_end_color">#ff000000</color>
The same behavior for gradient without center color:
<gradient
android:angle="90"
android:startColor="@color/fade_start_color"
android:endColor="@color/fade_end_color"
android:type="linear"/>
How can i draw a smooth linear gradient from black (or semi transparent black) to a full transparent?
I tried hardware acceleration on/off, 'getWindow().setFormat(PixelFormat.RGBA_8888);' Nothing helps me.
Update 1 I created a simple app at github. https://github.com/ralexey/TestApp Just an activity with color background and gradient over it.
add this line in your gradient android:centerY="y%p"
it may help you
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:centerY="25%p"
android:centerColor="@color/fade_center_color"
android:endColor="@color/fade_end_color"
android:startColor="@color/fade_start_color"
android:type="linear"
android:dither="true"
android:useLevel="true" />
</shape>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With