首页 > 技术文章 > match_parent的使用

achsnw 2014-11-08 09:53 原文

如果一个控件的宽、高使用match_parent属性,表示该控件的宽、高占剩下的所有区域。

例:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    <Button 
        android:id="@+id/login_btn"
        android:text="Login"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dip"
        />
    <WebView 
        android:id="@+id/login_webview"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dip"
        />

</LinearLayout>

效果:

推荐阅读