一:布局
<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" > <LinearLayout android:id="@+id/exit_layout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:layout_gravity="bottom" android:orientation="vertical" android:background="@drawable/exit_dialog_bg" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:gravity="center" android:textColor="#fff" android:textSize="16sp" android:text="退出后不会删除任何历史数据,下次\n登录依然可以使用本帐号" /> <Button android:id="@+id/exitBtn0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="退出登录" android:textSize="18sp" android:textColor="#fff" android:layout_marginTop="15dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="@drawable/btn_style_alert_dialog_special" android:gravity="center" android:onClick="exitbutton0" /> <Button android:id="@+id/exitBtn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp" android:text="取消" android:textSize="18sp" android:textColor="#fff" android:background="@drawable/btn_style_alert_dialog_cancel" android:gravity="center" android:onClick="exitbutton1" /> </LinearLayout> </LinearLayout> </RelativeLayout>
二:Activity的theme:
<style name="MyDialogStyleBottom" parent="android:Theme.Dialog" > <item name="android:windowAnimationStyle">@style/AnimBottom</item> <item name="android:windowFrame">@null</item><!--边框--> <item name="android:windowIsFloating">true</item><!--是否浮现在activity之上--> <item name="android:windowIsTranslucent">true</item><!--半透明--> <item name="android:windowNoTitle">true</item><!--无标题--> <item name="android:windowBackground">@android:color/transparent</item><!--背景透明--> <item name="android:backgroundDimEnabled">true</item><!--模糊--> </style>
<style name="AnimBottom" parent="@android:style/Animation"> <item name="android:windowEnterAnimation">@anim/push_bottom_in</item> <item name="android:windowExitAnimation">@anim/push_bottom_out</item> </style>
push_bottom_in
<?xml version="1.0" encoding="utf-8"?> <!-- 上下滑入式 --> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromYDelta="50%p" android:toYDelta="0" /> </set>
push_bottom_out
<?xml version="1.0" encoding="utf-8"?> <!-- 上下滑入式 --> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromYDelta="0" android:toYDelta="50%p" /> </set>
(在F:\java\j截取本地图片,或者相机拍照图片\My_Weixin)
package cn.bw.activitys; import android.app.Activity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; import android.widget.Toast; public class ExitFromSettings extends Activity { private LinearLayout layout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.exit_dialog_from_settings); //dialog=new MyDialog(this); layout=(LinearLayout)findViewById(R.id.exit_layout2); layout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "提示:点击窗口外部关闭窗口!", Toast.LENGTH_SHORT).show(); } }); } @Override public boolean onTouchEvent(MotionEvent event){ finish(); return true; } public void exitbutton1(View v) { this.finish(); } public void exitbutton0(View v) { this.finish(); MainWeixinActivity.instance.finish();//关闭Main 这个Activity } }