当前位置: 代码迷 >> Android >> Android 半透明(2)
  详细解决方案

Android 半透明(2)

热度:247   发布时间:2016-05-01 18:47:19.0
Android 半透明(二)

TranslucentBlurActivity

package org.wp.activity;import android.app.Activity;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.view.WindowManager;import android.widget.LinearLayout;public class TranslucentBlurActivity extends Activity {	private LinearLayout myLlay;	@Override	protected void onCreate(Bundle savedInstanceState) {		super.onCreate(savedInstanceState);		// Have the system blur any windows behind this one.		getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,				WindowManager.LayoutParams.FLAG_BLUR_BEHIND);		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) {				TranslucentBlurActivity.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_stag_finger" 	android:id="@+id/myLlay">	<!-- @drawable/tu_stag_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=".TranslucentBlurActivity"			android:theme="@style/Theme.Transparent" />	</application>	<uses-sdk android:minSdkVersion="8" /></manifest> 

?

styles.xml

<?xml version="1.0" encoding="utf-8"?><resources>	<!-- Base application theme is the default theme. -->	<style name="Theme" parent="android:Theme">	</style>	<!-- Variation on our application theme that has a transparent background; 		this example completely removes the background, allowing the activity to 		decide how to composite. Also here we force the translucency ourself rather 		than making use of the built-in translucent theme. -->	<style name="Theme.Transparent">		<item name="android:windowIsTranslucent">true</item>		<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>		<item name="android:windowBackground">@drawable/transparent_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="transparent_background">#00000000</drawable></resources>

?

?

?

  相关解决方案