How display a LinearLayout above a FrameLayout? - android

My code XML:
<?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:background="#777777"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dip"
android:layout_alignParentTop="true"
android:gravity="left|bottom"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="00:00:00"
android:textColor="#ffffff" />
</LinearLayout>
<FrameLayout
android:id="#+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="110dp"
android:background="#000000" >
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:gravity="center|top"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/button_Rotation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/my_progress_interminate" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
How display TextView txtTime above FrameLayout the same button button_Rotation?

I had fixed by move layout contain TextView down to under Framelayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#777777"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:id="#+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="110dp"
android:background="#000000" >
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dip"
android:layout_alignParentTop="true"
android:gravity="left|bottom"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="00:00:00"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:gravity="center|top"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/button_Rotation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/my_progress_interminate" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

outter linearLayout unless, then in your RelativeLayout
1st RelativeLayou: android:layout_alignParentTop="true", and set an id(#+id/rl)
2nd FrameLayout: android:layout_below="#id/rl"
3rd LinearLayout: android:layout_below="#id/camera_view"
That's all! Good luck!

It is the easiest way to do it:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FAFFD5" >
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical"
android:background="#drawable/textlayout_outline"
android:layout_margin="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/are_you_looking_for_something" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tap_here" />
</LinearLayout>

Related

Android linear layout, how to match remaining parent?

I am going to create a listview with two button at the bottom
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="#android:id/list"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task"
android:id="#+id/addTaskButton"></Button>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2"
android:id="#+id/addTaskButton2"></Button>
</LinearLayout>
</LinearLayout>
How to make the listview match the height to the remaining parent?
If I set a height to listview
android:layout_height="400dp"
this is not suitable to all device
If I set match_parent
android:layout_height="match_parent"
The listview will over the buttons at the bottom
If you set its height to 0dp and it's layout weight to 1, it will fill out the remaining space. Also, you don't need the LinearLayout surrounding the ListView.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#android:id/list" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task"
android:id="#+id/addTaskButton" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2"
android:id="#+id/addTaskButton2" />
</LinearLayout>
</LinearLayout>
This will work and I have also reduced number of lines in your code:
<?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:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/addTaskButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task" >
</Button>
<Button
android:id="#+id/addTaskButton2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2" >
</Button>
</LinearLayout>
</LinearLayout>
Use this layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#android:id/list"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task"
android:id="#+id/addTaskButton"></Button>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2"
android:id="#+id/addTaskButton2"></Button>
</LinearLayout>
</LinearLayout>
You may use this layout :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="#+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/lv_button"
android:layout_alignParentTop="true"
android:layout_marginBottom="#dimen/margin_bottom"
>
</ListView>
<LinearLayout
android:id="#+id/lv_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/margin_bottom"
android:layout_marginLeft="#dimen/margin_left"
android:layout_marginRight="#dimen/margin_right"
android:layout_marginTop="#dimen/margin_top"
android:orientation="horizontal" >
<Button
android:id="#+id/btn1"
android:layout_width="0.0dip"
android:layout_height="#dimen/button_height"
android:layout_marginRight="#dimen/margin_right"
android:layout_weight="1.0"
android:text="Button1"
/>
<Button
android:id="#+id/btn2"
android:layout_width="0.0dip"
android:layout_height="#dimen/button_height"
android:layout_marginLeft="#dimen/margin_left"
android:layout_weight="1.0"
android:text="Button2"
/>
</LinearLayout>
</RelativeLayout>
Use weight sum. Refer this link to know about weightsum
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:weightSum="10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#android:id/list"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="2"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task"
android:id="#+id/addTaskButton"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2"
android:id="#+id/addTaskButton2"></Button>
</LinearLayout>
</LinearLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:layout_width="match_parent"
android:layout_height="400dp"
android:id="#android:id/list"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="Add Task"
android:id="#+id/addTaskButton"></Button>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="Add Task2"
android:id="#+id/addTaskButton2"></Button>
</LinearLayout>
</LinearLayout>

Styling Custom adapter for gridview

What I am trying to get ::
< I am trying to display same look on both landscape and portrait mode>
What i am currently having ::
< Observe the imageview looks differently in different orientation modes > height of the imageview is more in portrait mode
grid_single.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222222"
android:orientation="vertical"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#E6E6E6"
android:orientation="vertical" >
<ImageView
android:id="#+id/grid_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/eleven" >
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:id="#+id/grid_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Text"
android:textSize="12sp" >
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<GridView
android:id="#+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#null"
android:listSelector="#00000000"
android:numColumns="auto_fit" />
</LinearLayout>
Try changing your ImageView xml to this:
<ImageView
android:id="#+id/grid_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:scaleType="fitXY"
android:src="#drawable/eleven" >
</ImageView>
You have a good sample of different android:scaleType displays, and how they behave here.
Use this XML instead..
grid_single.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#222222"
android:orientation="vertical"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#E6E6E6"
android:orientation="vertical" >
<ImageView
android:id="#+id/grid_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/eleven" >
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:id="#+id/grid_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Text"
android:textSize="12sp" >
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

How to set button under very large WebView on Android?

I have problem with setting button under large muptipage webview (User Agreement). Now I can see the button all the time while scrolling webview.
When I add android:layout_below="#+id/rl_relativeLayoutto button in layout, I can see only WebView content.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rl_relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip" >
<WebView
android:id="#+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rl_relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip" >
<Button
android:id="#+id/agreement_acceptance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:text="OK" />
</RelativeLayout>
Use ScrollView
<ScrollView android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<WebView android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
</ScrollView>
just add webView above the button and the button align to bottom ;)
In your case something like that
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rl_relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/agreement_acceptance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:text="OK" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rl_relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip"
android:layout_above="#+id/rl_relativeLayout2"
>
<WebView
android:id="#+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
</RelativeLayout>
Just replace this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/agreement_acceptance"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rl_relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dip" >
<WebView
android:id="#+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/agreement_acceptance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="OK" />

Intro layout problems with weight

I am creating an intro activity and What I want is that logo was double bigger than text, and the text was centered to the layout.
With the next code I am having problems with diferents layouts (in some screens the TextView is not shown:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/iconok" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
</LinearLayout>
What I am doing wrong?
As per your question and comments, I think below snippet will help you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="66"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/email_textview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="left|center"
android:layout_weight="33"
android:text="#string/app_name"
android:textSize="55sp" />
</LinearLayout>
(After your comment) then you should set first inner linear layout's weight 2, and second's 1. Also use layout_height =" 0" for them.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/iconok" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
test this code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.66" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/image_view_desc"
android:scaleType="fitCenter"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="0.34" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#string/loading_text3" />
</LinearLayout>
</LinearLayout>
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:weightSum="3"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#stringimage_view_desc"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="#drawable/image_view_desc" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="55sp"
android:text="#stringloading_text3" />
</LinearLayout>
</LinearLayout>
Try this and change margin according to your requirement.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:weightSum="3" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2" >
<ImageView
android:id="#+id/image_intro"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:contentDescription=""
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="abcd"
android:textSize="55sp" />
</LinearLayout>

How can I simplify my layout?

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>
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>
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>

Categories

Resources