日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

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

發(fā)布時(shí)間:2025/3/15 Android 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android activity透明主题,Android应用的全透明效果--Activity及Dialog的全透明 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.Activity全透明

同學(xué)給了這個(gè)有趣的代碼,現(xiàn)在公布出來。

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

#9000

這個(gè)值設(shè)定了整個(gè)界面的透明度,為了看得見效果,現(xiàn)在設(shè)為透明度為56%(9/16)左右。

再在res/values/下建styles.xml,設(shè)置程序的風(fēng)格<?xml version="1.0" encoding="utf-8"?>

@color/transparent

true

@+android:style/Animation.Translucent

最后一步,把這個(gè)styles.xml用在相應(yīng)的Activity上。即在AndroidManifest.xml中的任意標(biāo)簽中添加android:theme = "@style/transparent"

如果想設(shè)置所有的activity都使用這個(gè)風(fēng)格,可以把這句標(biāo)簽語句添加在中。

最后運(yùn)行程序,是不是發(fā)現(xiàn)整個(gè)界面都被蒙上一層半透明了。最后可以把背景色#9000換成#0000,運(yùn)行程序后,就全透明了,看得見背景下的所有東西可以卻都操作無效。很有趣吧。。。

2.Dialog全透明

1.準(zhǔn)備保留邊框的全透明素材如下圖:

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

@drawable/panel_background_sodino1

false

@style/TitleStyle

@style/TitleText

#000

3.在layout文件夾下新建一文件句為main_dialog.xml,內(nèi)容如下:<?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();

}

}

最后效果圖:

新人創(chuàng)作打卡挑戰(zhàn)賽發(fā)博客就能抽獎(jiǎng)!定制產(chǎn)品紅包拿不停!

總結(jié)

以上是生活随笔為你收集整理的android activity透明主题,Android应用的全透明效果--Activity及Dialog的全透明的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。