1.Activity全透明

同学给了这个有趣的代码,现在公布出来。

先在res/values下建colors.xml文件,写入:<?xmlversion ="1.0"encoding="UTF-8"?>

#9000

这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。

再在res/values/下建styles.xml,设置程序的风格<?xml version="1.0" encoding="utf-8"?>

@color/transparent

true

@+android:style/Animation.Translucent

最后一步,把这个styles.xml用在相应的Activity上。即在AndroidManifest.xml中的任意标签中添加android:theme = "@style/transparent"

如果想设置所有的activity都使用这个风格,可以把这句标签语句添加在中。

最后运行程序,是不是发现整个界面都被蒙上一层半透明了。最后可以把背景色#9000换成#0000,运行程序后,就全透明了,看得见背景下的所有东西可以却都操作无效。很有趣吧。。。

2.Dialog全透明

1.准备保留边框的全透明素材如下图:

2.在values中新建一styles.xml文件,内容如下:<?xml version="1.0" encoding="UTF-8"?>

@drawable/panel_background_sodino1

false

@style/TitleStyle

@style/TitleText

#000

3.在layout文件夹下新建一文件句为main_dialog.xml,内容如下:<?xml version="1.0" encoding="UTF-8"?>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#0000">

android:layout_width="wrap_content"

android:layout_height="200px"

android:layout_below="@+id/ImageView01"

android:background="#0000">

android:text="SodinoText"

android:textColor="#f000"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#0000"

>

android:layout_below="@id/ScrollView01"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:text="Cancel">

4.Activity代码如下:package lab.sodino.tanc;

import android.app.Activity;

import android.app.Dialog;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;

public class TANCAct extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Button btnShow = (Button) findViewById(R.id.btnShow);

btnShow.setOnClickListener(new Button.OnClickListener() {

public void onClick(View view) {

showTANC(

"This is my custom dialog box",

"TextContent/nWhen a dialog is requested for the first time, Android calls onCreateDialog(int) from your Activity, which is where you should instantiate the Dialog. This callback method is passed the same ID that you passed to showDialog(int). After you create the Dialog, return the object at the end of the method.",

"http://blog.csdn.net/sodino");

}

});

}

private void showTANC(String header, String content, String url) {

final Dialog dialog = new Dialog(this, R.style.TANCStyle);

dialog.setContentView(R.layout.main_dialog);

dialog.setTitle(header);

dialog.setCancelable(true);

TextView textView01 = (TextView) dialog.findViewById(R.id.TextView01);

textView01.setText(content + content + content);

Button btnCancel = (Button) dialog.findViewById(R.id.btnCancel);

btnCancel.setOnClickListener(new Button.OnClickListener() {

public void onClick(View view) {

dialog.cancel();

}

});

dialog.show();

}

}

最后效果图:

android activity透明主题,Android应用的全透明效果--Activity及Dialog的全透明相关推荐

  1. android 设置风格主题,Android Theme 常见主题风格详解

    本文为自己多年来在Android实战开发过程中总结归纳的一些常见问题,现在分享出来希望对初学者有所帮助. 目录 [1. 什么是Style,什么是Theme?] [2. 在定义Theme的时候@符号和? ...

  2. android 动态切换主题,android动态主题切换(RRO 技术)

    android上的主题切换,Android从M开始加入了动态资源overlay机制 runtime resource overlay(RRO),这个是sony贡献的,实现机制如下图,就是在框架中建立一 ...

  3. android 动态更改主题,Android应用动态修改主题的方法示例

    1.使用API设置主题 如下所示,在Activity中使用setTheme setTheme(R.style.MyTheme1); 2.调用API的时机 需要在super.onCreate(saved ...

  4. android studio导出主题,Android Studio插件美化Android Studio,文艺清新范(示例代码)

    一:重新定义你工作区的颜色 1:原生的工作区文字的颜色反人类,来这个网站下载自己喜欢的主题:http://www.riaway.com/  轻松定义:下载后是个jar包. 2:导入jar包 file ...

  5. android获取当前主题,Android – 从代码中引用当前应用主题中的属性值

    在XML中,它看起来像这样: style="?header_background" 在程序上,这有点棘手.在你的活动中 private static Theme theme = n ...

  6. android样式和主题

    样式(Style)是用来指定View或者window的外观和格式的一组属性集合.可以用来指定高度.内边距.字体颜色.字体大小.背景颜色等属性.样式定义在独立于布局文件的XML文件中.保证了内容和设计的 ...

  7. Android实现切换主题功能

    现在市面上有很多app都有更换主题皮肤的功能,那么到底是怎么实现的呢? 首先我们先上一张简单效果图 特别简单的实现,我们通过点击按钮切换主题 1.实现原理 实现起来特别简单,这里我们准备多个主题资源( ...

  8. android 启动页主题_如何使用主题和启动器个性化您的Android手机

    android 启动页主题 Android's customizability is one reason many people prefer it. You can change the look ...

  9. android java广播,[原]Android应用程序发送广播(sendBroadcast)的过程分析

    前面我们分析了Android应用程序注册广播接收器的过程,这个过程只完成了万里长征的第一步,接下来它还要等待ActivityManagerService将广播分发过来.ActivityManagerS ...

最新文章

  1. 操作系统内存管理——分区、页式、段式管理
  2. 设计模式系列·王小二需求历险记(一)
  3. Ansible基础概述
  4. idea内置junit5_JUnit的内置Hamcrest Core Matcher支持
  5. C language day1
  6. 百度云:centos7.0+ 安装宝塔与ShopXO开源商城(从0搭建到部署上线) - 教程篇
  7. [Swift]LeetCode79. 单词搜索 | Word Search
  8. 21天Jenkins打卡day8-配置SSH远程服务器
  9. java byte to integer_Java中的Byte转为无符号的Integer
  10. [JavaScript]面向对象编程
  11. mac sudo: /etc/sudoers is world writable
  12. matlab线性规划的最优化,【OR】Matlab求解最优化问题(1) 线性规划
  13. supervise进程管理利器
  14. TFT显示屏开发(一):接口定义和型号选择(0.96寸和1.8寸)
  15. 拼多多推广中出价是越高效果越好吗?
  16. 涂鸦画板,监听touch事件,手机端
  17. Imagemotion for Mac(PS动画插件)
  18. 梦幻西游 python.dll_GitHub - 10508zhl/mhxy: tensorflow实践:梦幻西游人物弹窗识别
  19. 关于PTR的说明【转】
  20. Sping为什么使用依赖注入而不使用实例化对象的方式?

热门文章

  1. Ubuntu根目录下各文件的功能介绍
  2. 弃医从码 | 从肄业少年到失业青年,再到科技工程师的逆袭人生路
  3. 用几张图片教你,财务分析的平台、架构、指标体系、模型
  4. 几大主流国产浏览器统一屏蔽996.ICU!
  5. Python入门:Anaconda和Pycharm的安装和配置
  6. 我们就要想办法的s9t9
  7. 【狂转】某个N人的访谈记录
  8. 飞秋文件传输模拟实现代码
  9. 5个不收费的自学网站:学英语、学编程、学电脑办公统统有
  10. 易混淆知识点(3):b和strong的真正区别在哪?