Why doesn't my layout resize using a Graphical Layout? - android-layout

I have added supports-screens to manifest, all UI elements values are in dip.
Why then I'm changing screen type in Graphical Layout my layout doesn't re-sizes?
I'm using LinearLayout, maybe better way is RelativeLayout?
Please help;
My Layout code:
<?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" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="#000000">
<TextView
android:id="#+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="20dip"
android:textStyle="bold"
android:layout_centerInParent="true"
android:text="Login" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#drawable/background"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/Image"
android:layout_width="280dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:layout_height="35dip"
android:src="#+drawable/logo_big"/>
<EditText
android:id="#+id/LoginName"
android:hint="Email"
android:layout_marginTop="20dip"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:inputType="textEmailAddress"/>
<EditText
android:hint="Password"
android:layout_marginTop="0dip"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:inputType="textPassword"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:password="true"
android:id="#+id/Password"/>
<Button
android:id="#+id/LogIn"
android:layout_marginTop="20dip"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="#+string/LogIn"/>
<TextView
android:id="#+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="center"
android:layout_marginTop="10dip"
android:textStyle="bold"
android:textSize="18dp"
android:text="#+string/DontHaveAnAccount"/>
<Button
android:id="#+id/SingUpNow"
android:layout_width="fill_parent"
android:layout_marginTop="10dip"
android:layout_height="45dip"
android:src="#+drawable/gray_button"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:background="#+drawable/primary_button"
android:clickable="true"
android:text="#+string/SingUpNow"/>
<Button
android:textColor="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_marginTop="10dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:id="#+id/ForgotYourPassword"
android:background="#+drawable/secondary_button"
android:text="#+string/ForgotYourPassword"/>
</LinearLayout>
</LinearLayout>
Help;

This tips maybe help you...
Avoid the use of graphical layout, just check you code there will be some hard code value or maybe there Absolute Layout..
To re-size the screen layout use Relative Layout... that will be fit for all screen..

Related

How to adjust screen size for all android devices

I just can't seem to find a way to fit the photo onto my home page screen, I've tried many different ways but it wasn't successful. I have an image that pushes the layout that is under it and squeezes the buttons on the screen. Is there any way I can auto resize the height it for different screens? I only need the height since the width should be match_parent. Below is the xml file.
<?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="#color/white"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/nav_bar_homepage" >
<TextView
android:id="#+id/pageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="WELCOME!" />
<ImageView
android:id="#+id/hiddenIcDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:src="#drawable/nav_icon"
android:visibility="invisible" />
</RelativeLayout>
<ImageView
android:id="#+id/horLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/headerLayout"
android:scaleType="center"
android:src="#drawable/line_big_white" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:scaleType="fitStart" >
<ImageView
android:id="#+id/image_homepage_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center_horizontal"
android:src="#drawable/image_homepage"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/field_red_homepage"
android:orientation="vertical"
android:scaleType="fitXY" >
<ImageView
android:id="#+id/logo_homep"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:paddingBottom="10dp"
android:scaleType="fitXY"
android:src="#drawable/logo_homepage" />
<ImageView
android:id="#+id/redeembytton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/btn_redeemrewards"
android:scaleType="fitXY" >
</ImageView>
<ImageView
android:id="#+id/orderbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#drawable/btn_orderonline"
android:scaleType="fitXY" >
</ImageView>
<ImageView
android:id="#+id/rewardsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#drawable/btn_earnrewards"
android:scaleType="fitXY" >
</ImageView>
<ImageView
android:id="#+id/referFriendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#drawable/btn_referafriend"
android:scaleType="fitXY" >
</ImageView>
</LinearLayout>
</LinearLayout>
Wrap you xml code into ScrollView if you are okay with scrolling down to reach your contents under ImageView. If you don't want to scroll down, it is best to use "weight" attribute. I am giving you an idea how to implement it in your code.
Let's say the height of the whole screen is 1. You have an image and a button to put on the screen for all devices. So split the screen into two parts... 0.8 for imageview and 0.2 for the button. You can use the code below to get this result.
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp" <!-- Important >
android:orientation="vertical"
android:layout_weight=".8" > <!-- 80% of your screen size>
<!-- Your ImageView >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp" <!-- Important >
android:orientation="vertical"
android:layout_weight=".2" > <!-- 20% of your screen size>
<!-- Your Button >
</LinearLayout>
</LinearLayout>
Try this
I think you should use
android:layout-weight="1" for adjusting the height according to different devices.use it in your <ImageLayout/>.

Android: How to understand layouts?

I am struggling big time with trying to make a simple layout with two TextView:s under each other on the left and corresponding two TimePicker:s under each other on the right. However, whichever view I use or attributes I choose that seem relevant I do not get the desired outcome. Here is my current try:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
>
<TextView
android:layout_column="1"
android:id="#+id/text_start_time"
android:text="#string/start_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_start"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
>
<TextView
android:layout_column="1"
android:id="#+id/text_end_time"
android:text="#string/end_time"
android:layout_gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_end"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
/>
</TableRow>
<TableRow>
<Button
android:layout_column="2"
android:layout_width="match_parent"
android:text="#string/button_calculate"
android:gravity="center"
android:onClick="calculateWorkingTime"
/>
</TableRow>
</TableLayout>
This gives the following output
Where is "Start"?
As you can see "Start" is not even shown! I would like to align "Start" with the vertical center of the TimePicker spinner. How to do that?
First, don't use a TableLayout. Use Linears, as you are a beginner and they're easier to use and understand. Here's what you should do:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/text_start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/start_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/text_end_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/end_time"
android:gravity="center_horizontal"
/>
<TimePicker
android:id="#+id/time_picker_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"
android:layout_marginTop="-25dp"
android:layout_marginBottom="-25dp"
android:layout_gravity="center"
/>
</LinearLayout>
<Button
android:layout_column="2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/button_calculate"
android:gravity="center"
android:onClick="calculateWorkingTime"
/>
</LinearLayout>
What I've done is creating a Linear Layout and, into it, another two with orientation:horizontal, which makes the elements appear one next to each other.
Also, I've put width and height to all the elements, what is very important.
I've put wrap_content, if you want to change it, no problem.
I didn't test it, if there's any error, just coment
Hope it helps!

Ripple on android.support.v7.widget.CardView when inflating ListView

I am inflating a ListView with a CardView layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.13"
android:padding="16dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/primary_text" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="112"
android:layout_marginRight="10dp"
android:padding="16dp"
android:paddingLeft="20dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/secondary_text" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="0.04"
android:elegantTextHeight="false"
android:padding="16dp"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/primary_text" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="129"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:padding="16dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="true" />
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>
and here is my ListView layout :
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/listView"
android:visibility="invisible"
android:paddingBottom="0dp"
android:background="#color/grey"
android:layout_gravity="center_horizontal|top"
android:divider="#color/white"
android:cacheColorHint="#android:color/transparent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:fastScrollEnabled="true"
android:layout_marginRight="0dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
The issue here is that I can't have the ripple effect on the card (I can only have it under the card) as you can see it here :
screenshot link
I've tried to put
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
on the cardview, but if I do this, I can't click on the card anymore (the onClick() function doesn't trigger anymore)
Would really appreciate some help understanding this.
It looks like you were close by adding the clickable and background, but you likely just need to select the right view to put the onClick listener on.
Did you try this?
view.findViewById(R.id.card_view).setOnClickListener(new View.OnClickListener)
view would be your LinearLayout with the id of lay.

Button text lost when in landscape mode

I have a simple screen with 4 buttons and their images:
and when I change it to landscape mode the images get cropped and the text is lost:
I am currently using a linear layout as follows:
<?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:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:background="#drawable/rings" >
<LinearLayout
android:id="#+id/row1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="top|fill_vertical"
android:orientation="horizontal" >
<Button
android:id="#+id/classesButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:contentDescription="#string/title_activity_class_list"
android:drawableBottom="#drawable/ic_classes"
android:onClick="viewClasses"
android:scaleType="fitCenter"
android:text="#string/classes"
android:minLines="1"
android:textColor="#android:color/primary_text_light" />
<Button
android:id="#+id/studentsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:drawableBottom="#drawable/ic_students"
android:onClick="viewStudents"
android:scaleType="fitCenter"
android:text="#string/students"
android:minLines="1"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
<LinearLayout
android:id="#+id/row2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|fill_vertical"
android:orientation="horizontal" >
<Button
android:id="#+id/levelsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:contentDescription="#string/levels"
android:drawableBottom="#drawable/ic_levels"
android:minLines="1"
android:onClick="viewLevels"
android:scaleType="fitCenter"
android:text="#string/levels"
android:textColor="#android:color/primary_text_light" />
<Button
android:id="#+id/skillsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:contentDescription="#string/skills"
android:drawableBottom="#drawable/ic_skills"
android:onClick="viewSkills"
android:scaleType="fitCenter"
android:text="#string/skills"
android:minLines="1"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
Update I changed the scale type to fitCenter and expected that to solve the issue but is has not. I am truly puzzled why scaling doesn't resize the image to fit inside the layout when it seems like others have found it does scale images to fit on screens.
I have experimented with using a relative layout but can't find an easy way to have the 4 buttons fill the screen equally.
Thanks in advance, I've spent far too much time on this!
You could change the Scale Type of the images to see which option would work best for you (may not work due to the fill_parent & Weight of Images).
You could make TextViews and put the Text above the images instead of having the button already with text (personal preference).
If you would link me with the four images I could figure it out for you :)
Markus
I finally figured out the layout which results in a scaled image that is visible along with the corresponding text. It took a lot of trial and error playing with Buttons, ImageButtons and ImageViews. The layout I am now using contains child linear layouts that are clickable which contains a text and image view.
<?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:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/rings"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/row1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:gravity="top|fill_vertical"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/classesLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:clickable="true"
android:onClick="viewClasses"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="#dimen/input_padding"
android:text="#string/classes"
android:textColor="#android:color/primary_text_light" />
<ImageView
android:id="#+id/classesIcon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_classes"
android:contentDescription="#string/classes"
android:minLines="1"
android:scaleType="fitCenter"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
<LinearLayout
android:id="#+id/studentsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:clickable="true"
android:onClick="viewStudents"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="#dimen/input_padding"
android:text="#string/students"
android:textColor="#android:color/primary_text_light" />
<ImageView
android:id="#+id/studentsIcon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_students"
android:contentDescription="#string/students"
android:minLines="1"
android:scaleType="fitCenter"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/row2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:baselineAligned="false"
android:gravity="bottom|fill_vertical"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/levelsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:clickable="true"
android:onClick="viewLevels"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="#dimen/input_padding"
android:text="#string/levels"
android:textColor="#android:color/primary_text_light" />
<ImageView
android:id="#+id/levelsButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_levels"
android:contentDescription="#string/levels"
android:minLines="1"
android:scaleType="fitCenter"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
<LinearLayout
android:id="#+id/skillsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#android:drawable/menuitem_background"
android:clickable="true"
android:onClick="viewSkills"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="#dimen/input_padding"
android:text="#string/skills"
android:textColor="#android:color/primary_text_light" />
<ImageView
android:id="#+id/skillsButton"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="#string/skills"
android:src="#drawable/ic_skills"
android:minLines="1"
android:scaleType="fitCenter"
android:textColor="#android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
The resulting portrait and landscape renderings are:

Android Linear layout and percentage

I want to create layout similar to one attached. The left hand side needs to be scrolled text occupying 75% of screen horizontally. The remaining 25% will consists of few icons stacked vertically and a button that should align at the bottom.
But I can't seem to get the working.
http://i.imgur.com/TzzBy9h.png
I would appreicate any help in getting this layout stuff right, my current layout looks like this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/card_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="50"
android:layout_weight="0.7"
android:gravity="bottom"
android:text="" >
</TextView>
<ImageView
android:id="#+id/photo_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:minHeight="84dp"
android:minWidth="84dp"
android:scaleType="centerCrop" />
</LinearLayout>
</ScrollView>
<LinearLayout android:gravity="center" android:orientation="horizontal"
android:padding="4.0dip" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/read_id_btn"
style="#style/PageButton"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="#string/read_id" />
</LinearLayout>
</LinearLayout>
~
Try weigth "2" and "1".
Good luck with it.
Try This code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginBottom="15dp"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>

Resources