笔记

1、判断是否是主线程

Looper.getMainLooper().getThread() == Thread.currentThread()

2、PopupWindow使用问题

在Android7.0上面如果使用如下方式会出现调用showAsDropDown方法PopupWindow顶到状态栏下方,而不是在指定View下方的现象,解决办法计算PopupWindow到屏幕底部实际需要的高度,不用MATCH_PARENT。

不合适

final PopupWindow window = new PopupWindow(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, true);
final PopupWindow window = new PopupWindow(view, FrameLayout.LayoutParams.MATCH_PARENT, getResources().getDisplayMetrics().heightPixels - xy - mTimeFilterView.getHeight(), true);
    private void showDateSelectDialog(View view, final FilterView floatFilterView) {
        int[] location = new int[2];
        mTimeFilterView.getLocationOnScreen(location);
        int y = location[1];
        int height = ScreenUtils.getScreenHeight(mActivity) - y - mTimeFilterView.getHeight();

        final PopupWindow window = new PopupWindow(view, FrameLayout.LayoutParams.MATCH_PARENT, height, true);
        // 设置PopupWindow的背景
        window.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#30000000")));
        // 设置PopupWindow是否能响应外部点击事件
        window.setOutsideTouchable(true);
        // 设置PopupWindow是否能响应点击事件
        window.setTouchable(true);
        window.getContentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                window.dismiss();
            }
        });

        window.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                floatFilterView.setOpened(false);
            }
        });

        PopupWindowCompat.showAsDropDown(window, mTimeFilterView, Gravity.BOTTOM, 0, 0);
    }

3、BottomNavigationView设置图片、文字颜色不被改变

BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setItemIconTintList(null);
navigation.setItemTextColor(getResources().getColorStateList(R.drawable.app_item_text_color));//color selector

或者使用库:

https://github.com/ittianyu/BottomNavigationViewEx







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值