Transparent layout in Android?
I am developing one android 开发者_JAVA百科application which use transparent activity.. I used the following link as reference but my problem is when i set background color as black i am not able see previous. i need transparent like this .
Thanks in Advance...
I had requirements to do the same thing in My Application, and I tried the above solution but unfortunately it didn't work for me.
After searching a lot for the same Issue, I have found one another solution That I would like to share here,
I have one Demo.java
activity for top and Test.java
Activity to show in background..So for that I have created one Style and applied to Demo.java ...and Magic..All Worked.!!
style.xml
<style name="Theme.D1NoTitleDim" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@android:color/transparent</item>
</style>
and in Manifest.xml
<activity android:name="Demo"
android:theme="@style/Theme.D1NoTitleDim"></activity>
Hope This will help Others Too. Enjoy Coding.!!
And you must make the following changes in the target activity (let's say splash activity):
public class SplashScreenActivity extends Activity {}
Be sure to extend it to the activity
Try setting your background color to somewhat transparent, i.e. #55000000
or '#5000'. Create colors.xml
in your res/values
folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#55000000</color>
</resources>
Then use the color in your theme style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourTheme" parent="android:@Theme.Translucent">
<item name="android:windowBackground">@color/background</item>
</style>
</resources>
Key thing here is to set Theme.Translucent
as parent of your style, I've tried same with Theme.Light
and that didn't work.
精彩评论