How to add child linear layout in android project - android-layout

Here is my XML file code I want to add 3 child linear layout to its parent layout how to do it
<LinearLayout
android:id="#+id/llTopMain"
android:layout_width="fill_parent"
android:layout_height="50dp"
>
<TextView
android:layout_width="fill_parent"
android:background= "#F778A1"
android:layout_height="50dp"/>
</LinearLayout>
<LinearLayout android:layout_above="#+id/llBottomMain"
android:layout_below="#id/llTopMain"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<LinearLayout
android:id="#+id/llMidMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/llMidMainExt1"
android:layout_width="fill_parent"
android:layout_height="50dp"
>
<TextView
android:layout_width="fill_parent"
android:background= "#FFFFFF"
android:layout_height="50dp"
/>
</LinearLayout>
***<LinearLayout
android:id="#+id/llMidMainExt2"
android:layout_width="fill_parent"
android:layout_height="50dp"
>***
<TextView
android:layout_width="fill_parent"
android:background= "#0F0F0F"
android:layout_height="50dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBottomMain"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
>
<TextView
android:layout_width="fill_parent"
android:background= "#F778A1"
android:layout_height="50dp"/>
</LinearLayout>
</RelativeLayout>
Here I cannot add android:id="#+id/llMidMainExt2" to its parent layout How to solve this? Thanks in advance.

Related

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>

GridView does not fill screen

I have a "grid_test.xml"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayoutGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<GridView
android:id="#+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="5dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" >
</GridView>
</LinearLayout>
I am including this in another layout with header and footer:
<?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="fill_parent"
android:id="#+id/commonlayout" >
<LinearLayout android:id="#+id/llheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#android:color/white">
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_gravity="center">
<Button
android:id="#+id/Button_Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="2dp"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher"/>
<Button
android:id="#+id/Button_settings"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
<ScrollView android:id="#+id/svdata"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_below="#+id/llheader"
android:layout_above="#+id/llfooter" >
<LinearLayout
android:id="#+id/lldata"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgound_color"
android:orientation="vertical"
android:padding="5dp" >
<include layout="#layout/grid_test" />
</LinearLayout>
</ScrollView>
<LinearLayout android:id="#+id/llfooter"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_margin="0dp"
android:layout_alignParentBottom="true"
>
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnOption1"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption2"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption3"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
My problem is that the included GridView layout does not fill the screen between header and footer.
What could be causing the problem?
Ok. I found it. Removing the ScrollView, makes it work as expected.
<?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="fill_parent"
android:id="#+id/commonlayout" >
<LinearLayout android:id="#+id/llheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#android:color/white">
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_gravity="center">
<Button
android:id="#+id/Button_Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="2dp"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher"/>
<Button
android:id="#+id/Button_settings"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lldata"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgound_color"
android:orientation="vertical"
android:layout_below="#+id/llheader"
android:layout_above="#+id/llfooter"
android:padding="5dp" >
<include layout="#layout/grid_test" />
</LinearLayout>
<LinearLayout android:id="#+id/llfooter"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_margin="0dp"
android:layout_alignParentBottom="true"
>
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnOption1"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption2"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption3"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>

display two layouts

I am trying to build a program where users data is displayed in table view while Home,About and Settings are to be displayed in TabLayout just below the table layout but TabLayout is not shown on screen while program runs. Here I have two class file one to display table layout whereas another to display TabLayout.Below is my main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="7dp">
<TextView
android:id="#+id/item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp"
android:textSize="10dp" />
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_left" android:textColor="#ffffffff"/>
<TextView android:text="Civil Bank " android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_middle" android:textColor="#ffffffff"/>
<TextView android:text="Sunrise Bank" android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_right" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Web user" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Transfer" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Cash" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_right" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_left" android:textColor="#ffffffff"/>
</TableRow>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</TableLayout>
</LinearLayout>
You have given the width and height of your tablelayout as fill-parent.So it would probably occupy the whole space of your linearlayout. Instead of fill-parent you have to use wrap-content. In tabhost you use the property android:layout_below="#+id/yourTableLayout".

Android: proper usage of RelativeLayout

I will try to represent the desired layout using text:
Stock Name
==========
symbol | score
GOOG | 76
symbol and GOOG should be in a single vertical Linear layout to group them and they should be aligned to the left score and 76 should also be in a a single vertical Linear layout to group them but they should be aligned to the right.
This is my layout. I could achieve it by the way you can see below. Does anyone got an idea what I am doing wrong? (this is only the relevant portion of the layout)
<?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="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/stock_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40dp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_symbol" />
<TextView
android:id="#+id/stock_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_score" />
<TextView
android:id="#+id/stock_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</LinearLayout>
</RelativeLayout>
I also tried using android:layout_alignLeft="#+id/relative_layout" and android:layout_alignRight="#+id/relative_layout" inside the LinearLayout but without success.
I found the error thanks to #RobinHood from the chat room "Android-People":
I had to replace the inner LinearLayouts with RelativeLayout and the inner RelariveLayout should change from android:layout_width="fill_parent" to android:layout_width="wrap_content"
<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:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/stock_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_symbol" />
<TextView
android:id="#+id/stock_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_score" />
<TextView
android:id="#+id/stock_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</RelativeLayout>
</RelativeLayout>

Resources