让自己的Activity变成透明的:关键是设置Activity的Theme。
1、定义一个style:
注意android:windowBackground的值必须要定义在color文件中,不能在这儿替换成:#50000000,不知道为什么,如果替换掉就会一直提示没有这个属性!不知道是我搞错了还是什么原因,有知道的朋友别忘了留言给我!
2、在AndroidManifest.xml文件声明Activity时给其添加Theme属性:
这样就可以让Activity透明了,透明度在color/transparent_background中调节,这个多说了!
1、定义一个style:
<style name="Transparent">
<item name="android:windowBackground">@color/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
<resources>
<color name="transparent_background">#A0000000</color>
</resources>
注意android:windowBackground的值必须要定义在color文件中,不能在这儿替换成:#50000000,不知道为什么,如果替换掉就会一直提示没有这个属性!不知道是我搞错了还是什么原因,有知道的朋友别忘了留言给我!
2、在AndroidManifest.xml文件声明Activity时给其添加Theme属性:
<activity android:name=".activity.PhotoGallery"
android:theme="@style/Transparent">
</activity>
这样就可以让Activity透明了,透明度在color/transparent_background中调节,这个多说了!