How do I create a transparent Activity on Android?

2018-12-31 00:29发布

I want to create a transparent Activity on top of another activity.

How can I achieve this?

19条回答
一个人的天荒地老
2楼-- · 2018-12-31 01:00

I wanted to add to this a little bit as I am a new Android developer as well. The accepted answer is great, but I did run into some trouble. I wasn't sure how to add in the color to the colors.xml file. Here is how it should be done:

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <color name="class_zero_background">#7f040000</color>
     <color name="transparent">#00000000</color>
</resources>

In my original colors.xml file I had the tag "drawable":

<drawable name="class_zero_background">#7f040000</drawable>

And so I did that for the color as well, but I didn't understand that the "@color/" reference meant look for the tag "color" in the XML. I thought that I should mention this as well to help anyone else out.

查看更多
登录 后发表回答