增加底部弹出泡泡菜单样例代码

This commit is contained in:
zengfantian 2015-01-12 17:14:33 +08:00
parent 5cde016689
commit 4b29c89aad
5 changed files with 207 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromYDelta="100%p"
android:toYDelta="0"
android:duration="500"
/>
<alpha
android:fromAlpha="0.7"
android:toAlpha="1.0"
android:duration="300"
/>
</set>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromYDelta="0"
android:toYDelta="100%p"
android:duration="3000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.5"
android:duration="2000"
/>
</set>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b0000000"
android:orientation="vertical" >
<TextView
android:id="@+id/showPop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="弹出POP"
android:textColor="#3995e1"
android:textSize="16sp" />
</LinearLayout>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#b0000000" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/white"
android:orientation="vertical" >
<TextView
android:id="@+id/mServerLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="登陆"
android:textColor="#3995e1"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#999999" />
<TextView
android:id="@+id/mSmsLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="注册"
android:textColor="#3995e1"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#999999" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="取消"
android:textColor="#3995e1"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,93 @@
package com.zftlive.android.sample.popupwindow;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.zftlive.android.R;
import com.zftlive.android.base.BaseActivity;
/**
* 底部弹出泡泡选择菜单样例
*
* @author 曾繁添
* @version 1.0
*
*/
public class PopDialogMenuActivity extends BaseActivity {
private View root ;
private PopupWindow popupWindow;
@Override
public int bindLayout() {
return R.layout.activity_pop_dialog;
}
@Override
public void initView(View view) {
// 父窗口view
root = findViewById(R.id.ll_root);
//触发弹窗的控件
TextView showPop = (TextView) view.findViewById(R.id.showPop);
showPop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.showAtLocation(root, Gravity.BOTTOM, 0, 0);
}
});
}
@Override
public void doBusiness(Context mContext) {
initPopupWindow();
}
@Override
public void resume() {
}
@Override
public void destroy() {
}
// 初始化方法
private void initPopupWindow() {
View contentView = getLayoutInflater().inflate(R.layout.activity_pop_dialog_menu, null);// 动态加载
TextView mServerLogin = (TextView) contentView.findViewById(R.id.mServerLogin);
TextView mSmsLogin = (TextView) contentView.findViewById(R.id.mSmsLogin);
mServerLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow.isShowing())
popupWindow.dismiss();
}
});
mSmsLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (popupWindow.isShowing())
popupWindow.dismiss();
}
});
// 全屏显示将内容设置在底部
popupWindow = new PopupWindow(contentView,ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setAnimationStyle(R.style.pop_animation);
}
}