android layoutinflater获取的textview无法改变值_Android 知识点一

1、使用代码设置textview的drawable

// 使用代码设置drawabletop
                Drawable drawable = getResources().getDrawable(
                        R.drawable.driver_home_ic_green);
                // / 这一步必须要做,否则不会显示.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                        drawable.getMinimumHeight());
                home_tv.setCompoundDrawables(null, drawable, null, null);
                home_tv.setTextColor(Color.parseColor("#FF52B68E"));

2、PopupWindow的使用

popupWindow = new PopupWindow(contentView,
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

        popupWindow.setTouchable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
//                makeWindowLight();
            }
        });

//        popupWindow.setTouchInterceptor(new OnTouchListener() {
//
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//
//                Log.i("mengdd", "onTouch : ");
//
//                return false;
//                // 这里如果返回true的话,touch事件将被拦截
//                // 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss
//            }
//        });

//        // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
//        // 我觉得这里是API的一个bug
//        popupWindow.setBackgroundDrawable(getResources().getDrawable(
//                R.drawable.pop_set));

        // 设置好参数之后再show
        popupWindow.showAsDropDown(view);

3、仿新浪微博添加效果

63b8e33fe431d96fa6eb4b85e5e64987.png

使用decorView方式(其实自己的布局也是可以的),decorView是framelayout方式。

mAnimateLayout = LayoutInflater.from(this).inflate(R.layout.pop_driver_main, null);
ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
ViewGroup contentView = (ViewGroup) decorView.findViewById(android.R.id.content);
contentView.addView(mAnimateLayout);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值