Reputation: 13
I'm a newbie developer, I created a layout which matches my expectations but I fear that its construction is too complex.
I used many layouts but I don't see how to build a similar layout without mixing linear and relative layouts, is it possible?
How can I simplify this layout? Thank you for your ideas.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/black_blue_gradient"
android:paddingBottom="5dip"
android:paddingTop="24dip" >
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/header" >
<LinearLayout
android:id="@+id/linearlayout01left"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="40"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="8dp"
android:layout_alignParentBottom="true"
android:background="@drawable/b_bgradient" >
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/oranwall_ovosh" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearlayout02right"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="60"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#E9EEF2"
android:gravity="center_vertical|center_horizontal"
android:text="@string/My_txt"
android:textColor="#535A5F"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Upvotes: 1
Views: 986
Reputation: 12293
Try it. Don't forget put your background and other resources
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableRow
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher">
</TableRow>
<TableRow
android:id="@+id/body"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/perm" />
<TableRow
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/ic_launcher" >
</TableRow>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</LinearLayout>
Upvotes: 2
Reputation: 16038
There are a few changes I would make:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<!-- I don't understand the point of this one: -->
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/black_blue_gradient"
android:paddingBottom="5dip"
android:paddingTop="24dip" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/linearlayout01left"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- I don't understand the point of this one -->
<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_alignParentBottom="true"
android:background="@drawable/b_bgradient" >
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/oranwall_ovosh" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearlayout02right"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#E9EEF2"
android:gravity="center_vertical|center_horizontal"
android:text="@string/My_txt"
android:textColor="#535A5F"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Upvotes: 1