what type of layout should i be used for a layout like this?
Should i be used linear layout or relative? Could you explain why you chose the layout you did. A sample would be helpf开发者_运维百科ul as well.
Thanks
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:background="#ff00" android:id="@+id/relativeLayout1"
android:layout_height="100dp" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"></RelativeLayout>
<RelativeLayout android:layout_width="match_parent"
android:background="#f0f0" android:id="@+id/relativeLayout2"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_above="@+id/relativeLayout1"
android:layout_centerHorizontal="true"></RelativeLayout>
</RelativeLayout>
If your layout is as simple as the above shown, I would use LinearLayout - mostly because I find working with relative layouts a bit annoying and harder to find bugs in.
A sample would be:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/linearLayout1"
android:orientation="vertical" android:layout_weight="1"
android:background="@android:color/darker_gray">
<!-- Put widgets here -->
</LinearLayout>
<LinearLayout android:layout_height="100dp"
android:layout_width="fill_parent" android:id="@+id/linearLayout2"
android:orientation="vertical" android:background="@android:color/background_light">
<!-- Put widgets here -->
</LinearLayout>
</LinearLayout>
精彩评论