android:maxHeight,android:maxWidth失效,不起作用

来源:互联网 发布:外国人北京奥运会知乎 编辑:程序博客网 时间:2024/05/21 10:21

版权声明:本文为Zhang Phil原创文章,欢迎转载!转载请注明出处:http://blog.csdn.net/zhangphil

在Android的布局文件中,设置某一个view的最大宽和最大高,比如ImageView,如果仅仅这么做:

android:maxHeight="25dip"  android:maxWidth="25dip"  

没有作用,完全失效。原因是:仅仅设置view的maxHeight和maxWidth是没有用的,必须同时联合设置:

android:adjustViewBounds="true"  

即同时设置如下参数,才可以正常生效:

android:adjustViewBounds="true"              android:maxHeight="25dip"              android:maxWidth="25dip"  
原创粉丝点击