`
onewayonelife
  • 浏览: 252980 次
  • 性别: Icon_minigender_1
  • 来自: 太原
社区版块
存档分类
最新评论

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>

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics