ImageView.getWidth() returns 0

前端 未结 4 1170
误落风尘
误落风尘 2020-12-08 21:28

I get imageView\'s width 0. Below is code.

xml file :



        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 22:01

    Since you already have a "fixed" width imageView of 200dp why don't you just put it in dimens.xml

    200dp
    

    and then simply

    int width = (int) getResources().getDimension(R.dimen.image_Width)
    

提交回复
热议问题