package com.example.blueapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class TestaActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.testa);
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new Tip(TestaActivity.this).show();
}
});
}
}
testa.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="学习"
android:textSize="22dp"
/>
</LinearLayout>
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@null</item>
</style>
package com.example.blueapp;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
public class Tip {
private ImageView image;
private Dialog mDialog;
public Tip(Context context) {
mDialog = new Dialog(context, R.style.dialog);
Window window = mDialog.getWindow();
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;
wl.y = 0;
window.setAttributes(wl);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
window.setGravity(Gravity.CENTER);
window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
mDialog.setContentView(R.layout.tip);
mDialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL, 0);
mDialog.findViewById(R.id.btn2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mDialog.dismiss();
}
});
}
public void show() {
mDialog.show();
}
}
tip.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="190dp"
android:background="#2BD5D5"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/upContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/description"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:text="1.this is the test text!\n
1.this is the test text!\n1.this is the test text!\n1.this is the test text!\n"
android:textColor="#000000" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher" />
</LinearLayout>
<Button
android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="跳出" />
</LinearLayout>