TranslucentActivity
package org.wp.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
public class TranslucentActivity extends Activity {
private LinearLayout myLlay;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.translucent_background);
myLlay = (LinearLayout) this.findViewById(R.id.myLlay);
myLlay.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
TranslucentActivity.this.finish();
return false;
}
});
}
}
translucent_background.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tu_handle_finger"
android:id="@+id/myLlay">
<!-- @drawable/tu_handle_finger 透明背景提示图片 -->
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.wp.activity" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TranslucentActivity" android:theme="@style/Theme.Translucent" />
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- A theme that has a translucent background. Here we explicitly specify
that this theme is to inherit from the system's translucent theme, which
sets up various attributes correctly. -->
<style name="Theme.Translucent" parent="android:style/Theme.Translucent">
<item name="android:windowBackground">@drawable/translucent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="translucent_background">#50000000</drawable>
</resources>
分享到:
相关推荐
Android 半透明菜单
Android 半透明Menu 效果源码
通过对画笔的设置,获取灰色遮盖,不用美工的图片也可以达到半透明遮盖的效果,节省了资源。
在布局页面加载时根据背景变换实现模糊和半透明的效果
Android 半透明对话框Demo源码
Android 仿UC半透明菜单!
Android PopupuWindow 背景半透明,设置最大高度
Android夜间模式实现,通过在window上加一层半透明的View,解决网上坑点,亲自在项目中尝试
Android屏幕适配之状态栏导航栏半透明、全透明(5.0以上去阴影),方法多样
android半透明对话框实现,小demo
[Android][半透明遮罩]
常用android颜色色值和半透明色值的设置
重载dialog,是周围出现透明磨砂的效果。点击dialog以外区域自动退出。
Android项目实现半透明的popupwindow.rar
Android 半透明对话框Demo源码.rar
Android 半透明Menu效果源码.rar
APP初始使用,半透明引导界面
Android 半透明对话框Demo源码.zip
Android 半透明Menu效果源码.zip
Android程序研发源码Android 半透明对话框Demo源码.rar