I have the following layout, where the edit texts goes out of the screen with apparently no reason. I've trying to find a similar issue but I couldn't. It should be an easy one but I've tried many things without luck.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridLayout
android:id="#+id/gridLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:columnCount="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/titleTextView"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="dsgsdgsd"
android:textColor="#color/red"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#color/red" />
<TextView
android:id="#+id/textTitle"
android:layout_gravity="left"
android:background="#ffffff"
android:paddingLeft="15dp"
android:text="Title"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editTitle"
android:layout_gravity="right"
android:inputType="text">
</EditText>
<View
android:layout_height="1dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:background="#E6E6E6" />
<TextView
android:id="#+id/textCategory"
android:layout_gravity="left"
android:background="#ffffff"
android:gravity="left"
android:paddingLeft="15dp"
android:text="Category"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editCategory"
android:layout_width="225dp"
android:layout_gravity="right"
android:inputType="text" />
<Button
android:id="#+id/btnCreateAccount"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ffffff"
android:onClick="createExpense"
android:text="Done"
android:textColor="#color/red" />
</GridLayout>
Check your updated code:
You were missing some width, height attributes, and you had used match_parent in earlier element like View, which prevented any later element to get space on screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridLayout
android:id="#+id/gridLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:columnCount="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="dsgsdgsd"
android:textColor="#color/red"
android:textStyle="bold" />
<View
android:layout_width="wrap_content"
android:layout_height="2dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#color/red" />
<TextView
android:id="#+id/textTitle"
android:layout_gravity="left"
android:background="#ffffff"
android:paddingLeft="15dp"
android:text="Title"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editTitle"
android:layout_gravity="right"
android:inputType="text" >
</EditText>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:background="#E6E6E6" />
<TextView
android:id="#+id/textCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="#ffffff"
android:gravity="left"
android:paddingLeft="15dp"
android:text="Category"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editCategory"
android:layout_width="225dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:inputType="text" />
<Button
android:id="#+id/btnCreateAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ffffff"
android:onClick="createExpense"
android:text="Done"
android:textColor="#color/red" />
</GridLayout>
</LinearLayout>
The output without color and background as it gives me error due to missing resource is:
Here you can see both your edittexts in screen.
try this may be this help you
<GridLayout
android:id="#+id/gridLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:columnCount="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/titleTextView"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="dsgsdgsd"
android:textColor="#color/red"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#color/red" />
<TableRow android:id="#+id/tableRow1" >
<TextView
android:id="#+id/textTitle"
android:background="#ffffff"
android:paddingLeft="15dp"
android:text="Title"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editTitle"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_weight="1"
android:inputType="text" >
<requestFocus />
</EditText>
</TableRow>
<View
android:layout_height="1dip"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:background="#E6E6E6" />
<TextView
android:id="#+id/textCategory"
android:layout_gravity="left"
android:background="#ffffff"
android:gravity="left"
android:paddingLeft="15dp"
android:text="Category"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editCategory"
android:layout_width="225dp"
android:layout_gravity="right"
android:inputType="text" />
<Button
android:id="#+id/btnCreateAccount"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ffffff"
android:onClick="createExpense"
android:text="Done"
android:textColor="#color/red" />
</GridLayout>
Change your EditText part to This one:
<EditText
android:id="#+id/editTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="center_horizontal|top"
android:layout_row="4"
android:ems="10"
android:inputType="text" />
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridLayout
android:id="#+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:columnCount="2"
android:orientation="horizontal" >
<TextView
android:id="#+id/titleTextView"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingBottom="10dp"
android:layout_row="0"
android:paddingTop="10dp"
android:text="dsgsdgsd"
android:textColor="#color/red"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_row="1"
android:layout_marginRight="20dp"
android:background="#color/red" />
<TextView
android:id="#+id/textTitle"
android:layout_gravity="left"
android:background="#ffffff"
android:paddingLeft="15dp"
android:layout_row="2"
android:layout_column="0"
android:text="Title"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editTitle"
android:layout_width="225dp"
android:layout_gravity="right"
android:layout_row="2"
android:layout_column="1"
android:inputType="text">
</EditText>
<View
android:layout_height="2dp"
android:layout_columnSpan="2"
android:layout_gravity="left"
android:layout_row="3"
android:background="#E6E6E6" />
<TextView
android:id="#+id/textCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="#ffffff"
android:gravity="left"
android:layout_row="4"
android:layout_column="0"
android:paddingLeft="15dp"
android:text="Category"
android:textColor="#color/grey" />
<EditText
android:id="#+id/editCategory"
android:layout_width="225dp"
android:layout_column="1"
android:layout_gravity="right"
android:layout_row="4"
android:inputType="text" />
<Button
android:id="#+id/btnCreateAccount"
android:layout_width="match_parent"
android:layout_gravity="center"
android:background="#ffffff"
android:layout_row="5"
android:layout_columnSpan="2"
android:onClick="createExpense"
android:text="Done"
android:textColor="#color/red" />
</GridLayout>
</LinearLayout>
As a general comment, you can never use wrap_content with EditText, it will always take the content size and not respect any other boundaries, so a user can always blow up a layout simply by typing excessive text. It took me ages to realise this very basic observation of how android prioritises various constraints.
In this context, when a GridLayout decides it cannot fit a column within its parent boundaries, it gives up and comes up with a faulty result, so typically we bound a GridLayout by screen width, the first column that exceeds the width will be forced off screen.
If you want to have large and small entry fields to match data sizes, the easiest way is to define dummy columns with weights that can be used to take up screen space, or spanned for larger fields.
Related
I have an android layout with some title bar and some input fields, and when I try to input some values, I can do it, but
the title bar vanishes
If I want to edit the field "Another number" I cannot scroll down to use the SeekBar instead.
How can I change the layout to make it
Have the title bar (with the text "InputExample") always fixes
Have the other content of the screen scrollable (so that I can use the SeekBar, for example)?
The layout is here:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccccc"
android:layout_marginBottom = "0dp">
<GridLayout
android:id="#+id/grid"
android:layout_margin="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/new_cancel"
android:alignmentMode="alignBounds"
android:columnCount="10"
android:columnOrderPreserved="false"
android:useDefaultMargins="true">
<TextView
android:id="#+id/textTitleEdit"
android:layout_column="0"
android:layout_columnSpan="10"
android:layout_gravity="center_horizontal"
android:layout_row="0"
android:text="My Title"
android:textSize="32dip"/>
<TextView
android:text="You can enter some values"
android:textSize="16dip"
android:layout_columnSpan="8"
android:layout_gravity="left"
android:id="#+id/textSubTitleEdit"
android:layout_row="1"
android:layout_column="0" />
<TextView
android:text="Name"
android:layout_gravity="right"
android:layout_row="2"
android:layout_column="0"
/>
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_name"
android:layout_row="2"
android:layout_column="1" />
_____________
<TextView
android:text="Label"
android:layout_gravity="right"
android:layout_row="3"
android:layout_column="0" />
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_label"
android:layout_row="3"
android:layout_column="1" />
______
<TextView
android:layout_column="0"
android:text="Put in a number"
android:layout_gravity="right"
/>
<EditText
android:ems="7"
android:singleLine="true"
android:id="#+id/new_price"
android:inputType="numberDecimal"
android:layout_row="4"
android:layout_column="1" />
<TextView
android:layout_column="0"
android:text="Another number"
android:layout_gravity="right"
android:layout_row="5" />
<EditText
android:ems="7"
android:singleLine="true"
android:id="#+id/new_offset"
android:inputType="number"
android:layout_row="5"
android:layout_column="1" />
<SeekBar
android:id="#+id/seek_offset"
style="#android:style/Widget.Holo.SeekBar"
android:layout_width="150dp"
android:layout_column="1"
android:layout_row="6"
android:max="20"/>
<TextView
android:text="Comment"
android:layout_gravity="right"
android:layout_row="7"
android:layout_column="0" />
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_comment"
android:layout_row="7"
android:layout_column="1" />
</GridLayout>
<Button
android:id="#+id/new_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#aaaaaa"
android:text="Cancel"
android:layout_margin="5dp"
/>
<Button
android:id="#+id/new_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#dddddd"
android:text="Ok"
android:layout_margin="5dp"
/>
</RelativeLayout>
</FrameLayout>
Was having some problems with your original layout so I've fixed it up and I think this solution should work. Everything in the preview of the layout has it positioned correctly so hopefully when you use this in the emulator it should work.
I personally prefer using LinearLayouts with weights for the majority of my layouts, I know some others prefer RelativeLayouts.
Essentially you should look to contain the part which you wish to scroll with a layout of some kind and then the ScrollView contains this layout so it can be scrolled. This is why I've removed the title and subtitle from the GridLayout.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccccc"
android:weightSum="6">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.5"
android:orientation="vertical"
android:gravity="bottom|center_horizontal">
<TextView
android:id="#+id/textTitleEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="My Title"
android:textSize="32dip"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You can enter some values"
android:textSize="16dip"
android:layout_gravity="center_horizontal"
android:id="#+id/textSubTitleEdit"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<GridLayout
android:id="#+id/grid"
android:layout_margin="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alignmentMode="alignBounds"
android:columnCount="10"
android:columnOrderPreserved="false"
android:useDefaultMargins="true">
<TextView
android:text="Name"
android:layout_gravity="right"
android:layout_row="2"
android:layout_column="0"/>
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_name"
android:layout_row="2"
android:layout_column="1"/>
<TextView
android:text="Label"
android:layout_gravity="right"
android:layout_row="3"
android:layout_column="0"/>
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_label"
android:layout_row="3"
android:layout_column="1" />
<TextView
android:layout_column="0"
android:text="Put in a number"
android:layout_gravity="right"
/>
<EditText
android:ems="7"
android:singleLine="true"
android:id="#+id/new_price"
android:inputType="numberDecimal"
android:layout_row="4"
android:layout_column="1" />
<TextView
android:layout_column="0"
android:text="Another number"
android:layout_gravity="end"
android:layout_row="5" />
<EditText
android:ems="7"
android:singleLine="true"
android:id="#+id/new_offset"
android:inputType="number"
android:layout_row="5"
android:layout_column="1" />
<SeekBar
android:id="#+id/seek_offset"
style="#android:style/Widget.Holo.SeekBar"
android:layout_width="150dp"
android:layout_column="1"
android:layout_row="6"
android:max="20"/>
<TextView
android:text="Comment"
android:layout_gravity="right"
android:layout_row="7"
android:layout_column="0" />
<EditText
android:ems="7"
android:singleLine="true"
android:inputType="textCapWords"
android:id="#+id/new_comment"
android:layout_row="7"
android:layout_column="1" />
</GridLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.5"
android:gravity="bottom|center_horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_weight="1">
<Button
android:id="#+id/new_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity=""
android:background="#aaaaaa"
android:text="Cancel"
android:layout_margin="5dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:layout_weight="1">
<Button
android:id="#+id/new_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#dddddd"
android:text="Ok"
android:layout_margin="5dp"/>
</RelativeLayout>
</LinearLayout>
I want to apply ScrollView to my entire screen. But scrollview can host only one direct child.
I have tried this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E9E0DB"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/dialogcreatemainlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/votes_bg"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:id="#+id/dialogimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="3dp" >
<ImageView
android:id="#+id/dialog_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/dialog_image" />
<ImageView
android:id="#+id/profimage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/member_80" />
<TextView
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#id/profimage"
android:text="By Hermoine - 2 days ago on Politics"
android:textColor="#040404"
android:textSize="12dp"
android:textStyle="normal"
android:typeface="sans" />
</LinearLayout>
<LinearLayout
android:id="#+id/pub_arc_rem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dialogimage"
android:orientation="horizontal"
android:weightSum="3" >
<Button
android:id="#+id/btnPublish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Publish"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnArchive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Archive"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnRemove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Remove"
android:textSize="12dp"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pub_arc_rem"
android:layout_marginTop="10dp"
android:text="There Is Nothing Negative In Total Exploitation Of Natural Resources. What Say?"
android:textColor="#343434"
android:textSize="12dp" />
<TextView
android:id="#+id/dialog_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/dialog_title"
android:layout_marginTop="10dp"
android:text="I don't think you have to believe one or the other. I have personally met christian's who simply think the big bang is how god created the universe. I have also met atheist who believe that we don't have the ability to know how the universe began. I have."
android:textColor="#343434"
android:textSize="12dp" />
<View
android:id="#+id/topformline"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/thumbnail"
android:layout_marginBottom="5dp"
android:layout_marginTop="6dp"
android:background="#android:color/darker_gray"
android:gravity="center" />
<LinearLayout
android:id="#+id/dialog_det"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/list_image"
android:layout_toRightOf="#+id/list_image"
android:layout_weight="5"
android:padding="5dip"
android:text="Last Active: 6 days ago"
android:textColor="#000000"
android:textSize="10dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/list_image"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:src="#drawable/member" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:padding="5dip"
android:text="8"
android:textColor="#000000"
android:textSize="10dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/list_image"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:src="#drawable/udebate_fav" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:padding="5dp"
android:text="64"
android:textColor="#000000"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/mod_friend"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dialogcreatemainlayout"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:id="#+id/btnAssignModerator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Assign Moderator"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnInviteFriends"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Invite Friends"
android:textSize="12dp"
android:textStyle="normal" />
</LinearLayout>
</ScrollView>
Can anyone please guide me?
Thanks.
Wrap the content inside a Contanier. One from FrameLayour, LinearLayout, RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E9E0DB"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- your components -->
</LinearLayout>
</ScrollView>
Here is how its done:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E9E0DB"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/dialogcreatemainlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/votes_bg"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:id="#+id/dialogimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="3dp" >
<ImageView
android:id="#+id/dialog_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/dialog_image" />
<ImageView
android:id="#+id/profimage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/member_80" />
<TextView
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#id/profimage"
android:text="By Hermoine - 2 days ago on Politics"
android:textColor="#040404"
android:textSize="12dp"
android:textStyle="normal"
android:typeface="sans" />
</LinearLayout>
<LinearLayout
android:id="#+id/pub_arc_rem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dialogimage"
android:orientation="horizontal"
android:weightSum="3" >
<Button
android:id="#+id/btnPublish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Publish"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnArchive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Archive"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnRemove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Remove"
android:textSize="12dp"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pub_arc_rem"
android:layout_marginTop="10dp"
android:text="There Is Nothing Negative In Total Exploitation Of Natural Resources. What Say?"
android:textColor="#343434"
android:textSize="12dp" />
<TextView
android:id="#+id/dialog_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/dialog_title"
android:layout_marginTop="10dp"
android:text="I don't think you have to believe one or the other. I have personally met christian's who simply think the big bang is how god created the universe. I have also met atheist who believe that we don't have the ability to know how the universe began. I have."
android:textColor="#343434"
android:textSize="12dp" />
<View
android:id="#+id/topformline"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/thumbnail"
android:layout_marginBottom="5dp"
android:layout_marginTop="6dp"
android:background="#android:color/darker_gray"
android:gravity="center" />
<LinearLayout
android:id="#+id/dialog_det"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/list_image"
android:layout_toRightOf="#+id/list_image"
android:layout_weight="5"
android:padding="5dip"
android:text="Last Active: 6 days ago"
android:textColor="#000000"
android:textSize="10dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/list_image"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:src="#drawable/member" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:padding="5dip"
android:text="8"
android:textColor="#000000"
android:textSize="10dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/list_image"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:src="#drawable/udebate_fav" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:padding="5dp"
android:text="64"
android:textColor="#000000"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/mod_friend"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/dialogcreatemainlayout"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:id="#+id/btnAssignModerator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Assign Moderator"
android:textSize="12dp"
android:textStyle="normal" />
<Button
android:id="#+id/btnInviteFriends"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Invite Friends"
android:textSize="12dp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
As you can see the ScrollView must have only one child.
just add vertical linearLyout after scrollview declaration and close the linearLayout before the scrolview tag is closed
<?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:orientation="vertical"
android:padding="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="75dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="35dp"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Multiples"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="85dp"
android:text="16"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Living"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="95dp"
android:text="17"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_centerVertical="true"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Ab Included"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="70dp"
android:text="13"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Ab Spontaneous"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="14"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Ectopics"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="35dp"
android:text="15"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
This is how the screen looks, can anyone tell me how can i achieve this layout. i have come up with the layout, but it seems it does not fit for all screens.
Make the LinearLayout width fill_parent to use the entire width of the screen.
Then for each TextView, set the layout_width to 0dp, and set layout_weight to the proportion of the screen you want that view to have.
In the padding, specify the minimum amount you want between the different cells.
For example, if you want the text to occupy double the space of the numbers, use the following code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Use TableLayout
Here is an example
I try to create somekind of stroke on top of my screen which displays 4 things. An backbutton on the left, the level name in the center and scoreInfoOne and scoreInfoTwo on the right, but below each other. I use following code, but the strange thing is that the level name doesn't appear to be centered, the longer the value of scoreInfoTwo is, the more the level name is on the left. Any ideas?
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:background="#25ab89"
android:orientation="horizontal"
android:weightSum="4" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBackButton"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="#drawable/arrow" />
</LinearLayout>
<TextView
android:id="#+id/tvScoreBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:text="level"
android:textColor="#ffffff"
android:textSize="18dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical"
android:paddingRight="2dp" >
<TextView
android:id="#+id/tvScoreInfoOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="0/30"
android:textColor="#ffffff"
android:textSize="12dp" />
<TextView
android:id="#+id/tvScoreInfoTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="score:"
android:textColor="#ffffff"
android:textSize="12dp" >
</TextView>
</LinearLayout>
Your child views must set the layout_width to zero:
android:layout_width="0px"
So your layout would then look like:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:background="#25ab89"
android:orientation="horizontal"
android:weightSum="4" >
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBackButton"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="#drawable/arrow" />
</LinearLayout>
<TextView
android:id="#+id/tvScoreBoard"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center"
android:text="level"
android:textColor="#ffffff"
android:textSize="18dp" />
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical"
android:paddingRight="2dp" >
<TextView
android:id="#+id/tvScoreInfoOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="0/30"
android:textColor="#ffffff"
android:textSize="12dp" />
<TextView
android:id="#+id/tvScoreInfoTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="score:"
android:textColor="#ffffff"
android:textSize="12dp" >
</TextView>
</LinearLayout>
First off, you cannot use android:layout_gravity="anything" in a LinearLayout. For LinearLayouts you use the weights to define how much space you want to use. For what you are trying to do, I suggest using a RelativeLayout then you can just define where you want your TextView or other items by using android:layout_below="#+id/other_textview and there are lots of android:layout_[direction] to choose from, and you can use layout_gravity="center_horizontal" with these.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="35dp"
android:background="#25ab89">
<ImageView
android:id="#+id/ivBackButton"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/arrow" />
<TextView
android:id="#+id/tvScoreBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_below="#id/ivBackButton"
android:gravity="center"
android:text="level"
android:textColor="#ffffff"
android:textSize="18dp" />
<TextView
android:id="#+id/tvScoreInfoOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_below="#id/tvScoreBoard"
android:alignParentRight="true"
android:text="0/30"
android:textColor="#ffffff"
android:textSize="12dp" />
<TextView
android:id="#+id/tvScoreInfoTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_below="#id/tvScoreInfoTwo"
android:alignParentRight="true"
android:text="score:"
android:textColor="#ffffff"
android:textSize="12dp" />
</RelativeLayout>
I have a problem and I really don't know now how to deal with it.This is my .xml file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:fillViewport="true"
android:overScrollMode="always"
android:scrollbarAlwaysDrawVerticalTrack="false" >
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rlActivityDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:overScrollMode="always" >
<ImageButton
android:id="#+id/ibStartTrip"
android:layout_width="95dp"
android:layout_height="80dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="10dp"
android:src="#drawable/car" />
<TextView
android:id="#+id/tvStartTrip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ibStartTrip"
android:layout_marginLeft="35dp"
android:textColor="#FFFFFF" />
<ImageButton
android:id="#+id/ibStartActivity"
android:layout_width="95dp"
android:layout_height="80dp"
android:layout_alignTop="#+id/ibStartTrip"
android:layout_toRightOf="#+id/ibStartTrip"
android:src="#drawable/tools" />
<TextView
android:id="#+id/tvStartActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ibStartActivity"
android:layout_centerHorizontal="true"
android:textColor="#FFFFFF" />
<ImageButton
android:id="#+id/ibEndActivity"
android:layout_width="95dp"
android:layout_height="80dp"
android:layout_alignTop="#+id/ibStartActivity"
android:layout_toRightOf="#+id/ibStartActivity"
android:src="#drawable/finish" />
<TextView
android:id="#+id/tvEndActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/ibEndActivity"
android:layout_below="#+id/ibEndActivity"
android:layout_marginRight="16dp"
android:textColor="#FFFFFF" />
<TableLayout
android:id="#+id/tableLayoutInfo"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_below="#+id/tvStartActivity"
android:layout_centerHorizontal="true" >
<TableRow
android:id="#+id/tableRow1"
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/number" />
<TextView
android:id="#+id/tvActivityIdValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:text="aaaaaaaaaaaaaaaa"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/activity_type" />
<TextView
android:id="#+id/tvActivityTypeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_column="1"
android:layout_weight="1"
android:text="aaaaaaaaaaaaaaaa"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/site" />
<TextView
android:id="#+id/tvSiteNameValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:textColor="#FFFFFF"
android:text="aaaaaaaaaaaaaa"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/brand" />
<TextView
android:id="#+id/tvBrandValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:gravity="fill_horizontal"
android:text="aaaaaaaaaaaaaaaaaa"
android:layout_weight="1"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView5"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/subject" />
<TextView
android:id="#+id/tvSubjectValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_column="1"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:textSize="16dp" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView6"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_column="0"
android:src="#drawable/text" />
<TextView
android:id="#+id/tvTextValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssssssssss"
android:textColor="#FFFFFF"
android:layout_weight="1"
android:textSize="16dp"
android:width="0dip" />
</TableRow>
</TableLayout>
<TableLayout
android:id="#+id/tableLayoutAssets"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tableLayoutInfo"
android:layout_centerHorizontal="true" >
<TableRow
android:id="#+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>
<HorizontalScrollView
android:id="#+id/horizontalScrollImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/tableLayoutAssets"
android:layout_marginTop="10dp">
<LinearLayout
android:id="#+id/myGallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
<ProgressBar
android:id="#+id/progressBarAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="#+id/tableLayoutAssets"
android:visibility="gone"
/>
<ImageButton
android:id="#+id/ibAddImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/horizontalScrollImageView"
android:src="#drawable/add_button"
android:layout_marginBottom="50dp"/>
</RelativeLayout>
</ScrollView>
As you can see I have 3 image buttons.Under them a table layout with 6 rows.After that another table layout which is populated dynamically and under that a horizontal scroll view which is populated dynamically with pictures,and an image button for adding new pictures.
Now,my problem is that every time i open the activity,after the pictures are loaded in the horizontal scroll view, the last row from my first table layout is disappearing(is not disappearing completely but its width is getting very small and it only fits one letter per row).
I think that after the pictures are loaded the entire layout is redrawing itself and the first table doesn't maintain his properties(the "weight" property also does't apply anymore after the pictures are loaded).I could really use some help.
Any suggestions will be appreciated. Thx.
There is no need for the android:width attribute on the last TextView. Remove it and the TextViews should behave.