一直一来对android:layout_height、android:layout_width、android:height、android:width这几个属性的关系有些不理解,既然有了android:layout_height和android:layout_width为什么还要有android:height、android:width呢?网上搜了好久发现都是重复一句扯淡的话,今天下午抽时间好好研究了下发现只有android:layout_height和android:layout_width的值是wrap_content的时候相应的android:height、android:width才起作用,即:android:layout_height和android:layout_width的值是wrap_content的时候,控件的最终大小是由android:height、android:width和控件的最小高度android:minHeight和最小宽度android:minWidth两者的最大值决定的。假设android:height为20px,而控件的最小高度android:minHeight为30px,那么当android:layout_height为wrap_content时,控件的高度是30px。
当android:layout_height和android:layout_width的值是match_parent或具体值(例如50dp、60px、30sp等)的时候,android:height、android:width是不起作用的。
本文深入探讨了Android中布局属性android:layout_height、android:layout_width与android:height、android:width之间的关系。揭示了当使用wrap_content时,如何通过android:height与android:width以及android:minHeight与android:minWidth来确定视图大小。
660

被折叠的 条评论
为什么被折叠?



