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

Android 半透明(1)

热度:214   发布时间:2016-05-01 18:47:16.0
Android 半透明(一)

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>

?

?

?

  相关解决方案