zoukankan      html  css  js  c++  java
  • Android 设置透明Activity

    关于Android设置Activity透明的方法有很多;这里介绍一种最简单的

    1。在MainActivity中放一个按钮;单击按钮是弹出透明的Activity

    2。透明的Activity只要在AndroidMainfest.xml中配置内加上

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

    即可设置成透明的Activity

    MainActivity代码很简单;只有一个按钮;单击按钮是弹出透明的Activity;

    透明Activity的布局文件如下: 在上面只放置了一个 ProgressBar

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:background="#9000" 
        >
        <!-- android:background="#9000" :透明颜色 -->
        
    	<ProgressBar 
    	    android:id="@+id/progress"
    	    android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:layout_centerInParent="true"
    	    style="@android:attr/progressBarStyleLarge"
    	    />
     
        
    </RelativeLayout>
    

     AndroidMainfest.xml设置

    <activity android:name="com.zhoucj.translucentactiivity.TranActivity"
                android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
                 />

    运行效果:

  • 相关阅读:
    Java Web学习笔记3
    Java学习笔记11
    diff 比较两个文件的差异
    Java学习笔记10
    appium——如何导出夜神模拟器下载“微信”app的apk
    python之文件操作模块(os和shutil)
    浅谈HTTP和HTTPS
    LUNIX命令集
    ubuntu软件管理工具的使用——dpkg和apt
    CSS学习—day1
  • 原文地址:https://www.cnblogs.com/zhoujian315/p/3272025.html
Copyright © 2011-2022 走看看