Android系统提供了将Activity设置为透明的主题:@android:style/Theme.Translucent

 

该属性同一时候支持隐藏TitleBar和全屏显示。

仅仅须要在AndroidManifest.xml配置文件里为相应的Activity添加该属性就可以。


<activity
            android:name=".activities.MyActivity"

            android:theme="@android:style/Theme.Translucent.NoTitleBar" />


假设希望实现半透明的效果,首先将Activity设置为透明。然后将Activity的布局文件的全局背景设置为半透的颜色值。


<?xml version="1.0" encoding="utf-8"?

> <RelativeLayout xmlns:andro xmlns:stepset="http://schemas.android.com/apk/res/******" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#70000000"> </RelativeLayout>



相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2021-09-05
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案