第十五讲:match_parent和fill_parent的区别

永远要相信边上的人比你聪明。


本讲内容:match_parent和fill_parent的区别:

由于match_parent更贴切,从Android 2.2开始FILL_PARENT改名为MATCH_PARENT  

所以从2.2开始你两个词都可以用。如果考虑低版本的使用情况你就需要用fill_parent了。

查看android.view.ViewGroup里的静态嵌套类LayoutParams中的代码就知道这俩者是相同的了:

public static final int FILL_PARENT = -1;  
   /** 
    * Special value for the height or width requested by a View. 
    * MATCH_PARENT means that the view wants to be as big as its parent, 
    * minus the parent's padding, if any. Introduced in API Level 9. 
    */ 
   public static final int MATCH_PARENT = -1;  
    
   /** 
    * Special value for the height or width requested by a View. 
    * WRAP_CONTENT means that the view wants to be just large enough to fit 
    * its own internal content, taking its own padding into account. 
    */


本讲到这里,谢谢大家!

你可能感兴趣的:(Android基础)