Android: How to get a custom View's height and width? [duplicate]

来源:互联网 发布:ajax传递表单数据 编辑:程序博客网 时间:2024/06/13 05:45

Sorry, this question was already asked. I found the answer here - How to size an Android view based on its parent's dimensions

@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {    int parentWidth = MeasureSpec.getSize(widthMeasureSpec);    int parentHeight = MeasureSpec.getSize(heightMeasureSpec);    this.setMeasuredDimension(parentWidth, parentHeight);    super.onMeasure(widthMeasureSpec, heightMeasureSpec);}

http://stackoverflow.com/questions/4074937/android-how-to-get-a-custom-views-height-and-width


0 0
原创粉丝点击