Button after listview crashing the app— XML

前端 未结 2 1394
旧时难觅i
旧时难觅i 2021-01-26 05:15

I dont know why but i cant get my button to show up after the listview. It does show fine in eclipse-graphical layout but when i launch the emulator the program crashes... here

相关标签:
2条回答
  • 2021-01-26 05:27

    Try not to use RelativeLayout in such complex markup. Use LinearLayout instead as baya described. RelativeLayout is good when you want your widgets to lie on each other, for example dvd_box template and movie's cover on it.

    And also if you use LinearLayout distribute it's space between it's children using android:layout_weight. It's realy useful and clear during reading your code if you express it in percentage terms.

    0 讨论(0)
  • 2021-01-26 05:42
    <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent">
    
        <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
            <TextView android:layout_width="match_parent" android:layout_height="wrap_content"/>
            <TextView />
            <TextView />
        </RelativeLayout>       
    
        <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" />
    
        <Button  android:layout_width="match_parent" android:layout_height="wrap_content"/>
        <Button  android:layout_width="match_parent" android:layout_height="wrap_content"/>
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题