I am trying to make a bar fade in to the background of my RelativeLayout. Basically start off from back and then fade to being transparent. You get the idea.
Here's the xml I have now:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/black_translucent"
android:endColor="#323232"
android:angle="90"
android:type="linear"
android:useLevel="true"
/>
</shape>
And the View I applied this to:
<View
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@drawable/gradient_top" />
The problem: the View has a sharp ending edge at the bottom. I am confused since the gradient ends in transparent. However I still get a shark edge at the bottom of the View. How can I tweak this to get a fading edge?
Transparent background is one of the most popular feature for android apps because with the transparent effect android application developer can easily build smooth glass effect android apps or apps that works same as widgets.
When using @android:color/transparent you need to remember that it represents a completely transparent version of a particular color (opacity set to 0%; A component is equal to #00). You cannot forget this color has its own RGB components which are NOT skipped when calculating gradient values.
So your background color would be #33FFFF00 Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. In the above code we have give 20% transparent yellow background for text view.
You can customize the colors of the gradient according to your image theme. To do so, tap on the gradient and select the Colors icon to choose the colors you wish to apply. You can go with the Document Colors to add the best-suited colors for your gradient. 4. Adjust the Transparency The last step is to adjust the transparency of the gradient.
Neither of your colours are transparent.
@color/black_translucent
suggests that it's translucent, not transparent.
You could use @android:color/transparent
instead.
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