PopupWindow实现微信右上角菜单

本文介绍了如何在Android应用中通过自定义PopupWindow实现类似微信右上角菜单的效果,包括所需的资源图片、PopupWindow的入场动画设置以及自定义布局的XML文件配置。
摘要由CSDN通过智能技术生成

蛋疼的各种仿照效果,UI一定要伺候好,不然一言不合就给你来一个很NB的效果


上代码!

1.资源图片

        


2.popupWindow入场动画

<style name="AnimationPreview">
    <item name="android:windowEnterAnimation">@anim/fade_in</item>
    <item name="android:windowExitAnimation">@anim/fade_out</item>
</style>

3.自定义popupWindow


package com.amistrong.beautifulstar.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.amistrong.beautifulstar.chat.activity.GroupChatActivity;
import com.amistrong.beautifulstar.R;
import com.amistrong.beautifulstar.find.ui.activity.friend.MyFriendActivity;
import com.amistrong.beautifulstar.utils.scancodetool.decoding.Intents;

public class MorePopWindow extends PopupWindow {
    private View conentView;
    private String userId;
    public MorePopWindow(final Activity context) {
        final LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        conentView = inflater.inflate(R.layout.popup_window_chat, null);
        int h = context.getWindowManager().getDefaultDisplay().getHeight();
        int w = context.getWindowManager().getDefaultDisplay().getWidth();
        this.setContentView(conentView);
        this.setWidth(LayoutParams.WRAP_CONTENT);
        this.setHeight(LayoutParams.WRAP_CONTENT);
        //设置点击隐藏的属性
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        this.update();
        ColorDrawable dw = new ColorDrawable(0000000000);
        this.setBackgroundDrawable(dw);
        thi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值