自定义 仿QQ底部菜单popWindow


实现方法    点击时mPopupWindow.dismiss();

protected void popWindow(View parent) {

// TODO Auto-generated method stub
View view = null;
if (mPopupWindow == null) {
LayoutInflater lay = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = lay.inflate(R.layout.popbottom, null);
// 初始化按钮
renaming = (TextView) view.findViewById(R.id.pop1);
guanlian = (TextView) view.findViewById(R.id.pop2);
delete = (TextView) view.findViewById(R.id.pop3);
cancle = (TextView) view.findViewById(R.id.pop4);


mPopupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
}
// 使窗口里面的空间显示其相应的效果,比较点击button时背景颜色改变。
// 如果为false点击相关的空间表面上没有反应,但事件是可以监听到的。


mPopupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0);
mPopupWindow.setAnimationStyle(R.style.popupAnimation);
mPopupWindow.setFocusable(true);
mPopupWindow.setOutsideTouchable(true);


}



popbottom布局文件

<?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="wrap_content"
    android:background="@color/panel_bg"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:orientation="vertical" >
    <TextView 
        
        android:gravity="center"
        android:text="请做出你的选择"
        android:textSize="15sp"
        android:textColor="@color/text_black"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="fill_parent"
        android:background="@drawable/yuankuang2"
        android:layout_height="wrap_content"
        />
    <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="0.5dp"
        android:background="@drawable/fengexian2"
        />
    <TextView 
        android:id="@+id/pop1"
        android:gravity="center"
        android:text="重命名"
        android:textColor="#3079B2"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:textSize="18sp"
        android:layout_width="fill_parent"
        android:background="@drawable/yuankuang2"
        android:layout_height="wrap_content"
        />
     <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="0.5dp"
        android:background="@drawable/fengexian2"
        />
    <TextView 
        android:id="@+id/pop2"
        android:gravity="center"
        android:text="关联患者"
        android:textColor="#3079B2"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:textSize="18sp"
        
        android:layout_width="fill_parent"
        android:background="@drawable/yuankuang2"
        android:layout_height="wrap_content"
        />
     <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="0.5dp"
        android:background="@drawable/fengexian2"
        />
    <TextView 
        android:id="@+id/pop3"
        android:gravity="center"
        android:text="删除"
        android:textColor="#3079B2"
        android:textSize="18sp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="fill_parent"
        android:background="@drawable/yuankuang2"
        android:layout_height="wrap_content"
        />
    
    <TextView 
        android:id="@+id/pop4"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:gravity="center"
        android:text="取消"
        android:textColor="#3079B2"
        android:textSize="18sp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="fill_parent"
        android:background="@drawable/yuankuang2"
        android:layout_height="wrap_content"
        />


</LinearLayout>



style

popupAnimation

 <style name="popupAnimation" parent="android:Animation">
        <item name="android:windowEnterAnimation">@anim/pop_translate_in</item>
        <item name="android:windowExitAnimation">@anim/pop_translate_out</item>
    </style>

anim

in

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator" >


    <translate
        android:duration="1000"
        android:fromYDelta="100%p"
        android:toYDelta="60%p" />


</set>

out

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator" >


    <translate
        android:duration="1000"
        android:fromYDelta="60%p"
        android:toYDelta="100%p" />


</set>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值