zoukankan      html  css  js  c++  java
  • Android 透明主题

    转至:https://blog.csdn.net/zhangwenchaochao/article/details/78654128

    Activity采用透明主题有两种方式:

    重要的内容说三遍:
    采用透明主题的Activity一定要继承Activity,不然会崩溃。
    采用透明主题的Activity一定要继承Activity,不然会崩溃。
    采用透明主题的Activity一定要继承Activity,不然会崩溃。

    方法一
    在你的AndroidManifest里的Activity标签里配置透明主题:

    android:theme=”@android:style/Theme.Translucent”
    android:theme=”@android:style/Theme.Translucent.NoTitleBar”
    android:theme=”@android:style/Theme.Translucent.NoTitleBar.Fullscreen”

    第一种保留标题和状态栏,其他为透明色
    第二种保留状态栏,其他为透明色
    第三种全屏透明

    以上三种选一种即可。

    例子
    <activity android:name=".touming1Activity" android:theme="@android:style/Theme.Translucent" />
    1
    2
    这是刚刚进来的界面,没有透明

     

    采用第一种透明模式:

     

    方法二
    自己定义一种样式,然后在AndroidManifest的Activity标签中采用。

    例子
    在value的styles中定义如下style

    <style name="Transparent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    </style>
    1
    2
    3
    4
    5
    别忘了在colors里面定义透明色调

    <color name="transparent">#00000000</color>
    1
    然后在AndroidManifest的Activity标签中采用:

    <activity android:name=".touming2Activity" android:theme="@style/Transparent" />
    ---------------------
    作者:时光匠
    来源:CSDN
    原文:https://blog.csdn.net/zhangwenchaochao/article/details/78654128
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    VC++ 进度条的使用
    VC++ 知识点
    VC++ 遍历目录
    VC++ 目录选择对话框
    VC中的树形控件
    C++文件输入输出流
    一些有用的Sql语句
    C语言 单引号和双引号的区别
    如何让自己成为一名黑客高手全集
    顶尖黑客的故事
  • 原文地址:https://www.cnblogs.com/jdhdevelop/p/11130462.html
Copyright © 2011-2022 走看看