setLayoutParams()无效问题

    xiaoxiao2021-03-25  167

    iv_address = (ImageView) findViewById(R.id.iv_address);//加载xml布局的imageview RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParam)siv_address.getLayoutParams();//获得layoutParams //写你的对layoutParams更改代码 iv_address.setLayoutParams(layoutParams);//更新为你想设置的layoutParams

    运行后无效,怀疑是因为设置的layoutParams为同一个引用,系统认为没改变所以设置没刷新,待后面学到相关后研究一下

    更改为new一个对象后设置成功:

    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(iv_address.getLayoutParams());

    转载请注明原文地址: https://ju.6miu.com/read-4012.html

    最新回复(0)