Which layout have to use - android

I am new to android app development.I am developing an android app which is having a design like the following one.Which layout I have to use.If I use Linear layout I cannot place "Product Amount" Textview and Editbox in a stright line.Please help me to solve this.

you can do this using Linear Layout also
Try below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Product Amount"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/editText1"
android:layout_width="140dp"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
>
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<EditText
android:id="#+id/editText2"
android:layout_width="80dp"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="TextView" />
<EditText
android:id="#+id/editText3"
android:layout_marginLeft="5dp"
android:layout_width="80dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<EditText
android:id="#+id/editText4"
android:layout_width="80dp"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="TextView" />
<EditText
android:id="#+id/editText6"
android:layout_marginLeft="5dp"
android:layout_width="80dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
See below it's give me output like this

You will have to use more than one layout. Your xml will be something like this.
Linear Layout main (Vertical)
Linear Layout1 (Horizontal) - for first row.
Layout 1 ends
Linear Layout2 (Horizontal) - for second row.
Layout 2 ends
Linear Layout3 (Horizontal) - for third row.
Layout 3 ends
Text Sale Amt
Layout main ends
Edit:
<?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:id="#+id/l1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="3dip"
android:layout_weight="1"
android:padding="3dip"
android:text="Name" />
<EditText
android:id="#+id/nameedt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="3dip"
android:layout_weight="1"
android:inputType="textNoSuggestions"
android:padding="3dip" />
</LinearLayout>
<LinearLayout
android:id="#+id/l2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="3dip"
android:padding="3dip"
android:layout_weight="1"
android:text="Password" />
<EditText
android:id="#+id/pwdedt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="3dip"
android:inputType="textNoSuggestions"
android:layout_weight="1"
android:padding="3dip" />
</LinearLayout>
<TextView
android:id="#+id/pwdhint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="3dip"
android:padding="3dip"
android:layout_weight="1"
android:text="PasswordHint : HINT"
android:layout_gravity="center"/>
</LinearLayout>

You Should use TableLayout, with First Row Having four columns, use col span to extend a column for two columns, add View, where Cell isnt exist.

Related

Android - Cannot allign two buttons in LinearLayout

I've created a form using LinearLayout. All the objects appear fine, except for two buttons.
I'm trying to align them in a there own LinearLayout, but for some reason one of them is always lower than the other.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="il.ac.shenkar.david.todolistex2.InviteMember"
tools:showIn="#layout/activity_invite_member">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:id="#+id/invitememberLayout1">
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Invite Team Members"
android:id="#+id/invitememebrsView"
android:textSize="32sp"
android:layout_alignTop="#+id/invitememberLayout1"
android:layout_centerHorizontal="true"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:paddingLeft="25dp"
android:orientation="vertical"
android:id="#+id/invitememberLayout2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Enter Team Member Email"
android:layout_marginTop="60dp"
android:paddingLeft="45dp"
android:id="#+id/memberemail"
android:layout_alignTop="#+id/createteamLayout2"
android:layout_centerHorizontal="true"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="8"
android:minLines="1"
android:layout_marginTop="20dp"
android:hint=" mycool#emailaddress.com"
android:inputType="textEmailAddress"
android:digits="0,1,2,3,4,5,6,7,8,9,qwertzuiopasdfghjklyxcvbnmABCDEFGHIJKLMNOPQRSTUVWXYZ,#,."
android:textSize="16sp"
android:id="#+id/editemailaddress" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Phone Number"
android:layout_marginTop="30dp"
android:paddingLeft="85dp"
android:id="#+id/memberphonetextView"
android:layout_alignTop="#+id/invitememberLayout2"
android:layout_centerHorizontal="true"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:maxLength="10"
android:textSize="16sp"
android:hint=" Only digits allowed"
android:id="#+id/memberuserphonenumber" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Invite Member"
android:layout_marginTop="20dp"
android:layout_marginLeft="80dp"
android:layout_alignTop="#+id/createteamLayout2"
android:id="#+id/invitebtn"
android:onClick="onInviteMember" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:orientation="vertical"
android:id="#+id/invitememberLayout4">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:id="#+id/Donebtn"
android:onClick="onDonebtn"
android:layout_gravity="right" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"
android:id="#+id/Exitbtn"
android:onClick="onExitbtn"/>
</LinearLayout>
Here is the UI
It's bcz you have defined orientation to vertical.
Replace this code in your XML.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="il.ac.shenkar.david.todolistex2.InviteMember"
tools:showIn="#layout/activity_invite_member">
<LinearLayout
android:id="#+id/invitememberLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"></LinearLayout>
<TextView
android:id="#+id/invitememebrsView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/invitememberLayout1"
android:layout_centerHorizontal="true"
android:text="Invite Team Members"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="32sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/invitememberLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:orientation="vertical"
android:paddingLeft="25dp">
<TextView
android:id="#+id/memberemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/createteamLayout2"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:paddingLeft="45dp"
android:text="Enter Team Member Email"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<EditText
android:id="#+id/editemailaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:digits="0,1,2,3,4,5,6,7,8,9,qwertzuiopasdfghjklyxcvbnmABCDEFGHIJKLMNOPQRSTUVWXYZ,#,."
android:hint=" mycool#emailaddress.com"
android:inputType="textEmailAddress"
android:lines="8"
android:minLines="1"
android:textSize="16sp" />
<TextView
android:id="#+id/memberphonetextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/invitememberLayout2"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:paddingLeft="85dp"
android:text="Phone Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<EditText
android:id="#+id/memberuserphonenumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint=" Only digits allowed"
android:inputType="phone"
android:maxLength="10"
android:textSize="16sp" />
<Button
android:id="#+id/invitebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/createteamLayout2"
android:layout_marginLeft="80dp"
android:layout_marginTop="20dp"
android:onClick="onInviteMember"
android:text="Invite Member" />
</LinearLayout>
<LinearLayout
android:id="#+id/invitememberLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="#+id/Donebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:onClick="onDonebtn"
android:text="Done" />
<Button
android:id="#+id/Exitbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onExitbtn"
android:text="Exit" />
</LinearLayout>
</RelativeLayout>
And it's Done.
Because you gave the LinearLayout which contains the buttons a vertical orientation, change it to horizontal
android:orientation="horizontal"
In your LinearLayout which contains the 2 buttons -
replace -
android:orientation="vertical"
with
android:orientation="horizontal"
Because you want your buttons to be arranged horizontally.
Orientation in LinearLayout means One after another
So don't use orientation vertical in last LinearLayout:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:orientation="horizontal"
android:id="#+id/invitememberLayout4">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:id="#+id/Donebtn"
android:onClick="onDonebtn"
android:layout_gravity="right" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"
android:id="#+id/Exitbtn"
android:onClick="onExitbtn"/>
</LinearLayout>
Or other way you can do this is to change LinearLayout with buttons with RelativeLayout like that
<RelativeLayout
android:id="#+id/invitememberLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp">
<Button
android:id="#+id/Donebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onDonebtn"
android:layout_alignParentRight="true"
android:text="Done"/>
<Button
android:id="#+id/Exitbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onExitbtn"
android:layout_alignParentLeft="true"
android:text="Exit"/>
</RelativeLayout>
in last linearlayout which contain done and exit . set -
android:orientation="Horizontal"
let me know if it helps you.
Add android:orientation="horizontal" in last LinearLayout. And If you want to align these two buttons left and right side I suggest you to use RelativeLayout instead of LinearLayout.
Try this one :
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="370dp"
android:orientation="horizontal"
android:id="#+id/invitememberLayout4"
android:weightSum="3">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Invite Member"
android:layout_marginTop="20dp"
android:layout_marginLeft="80dp"
android:layout_alignTop="#+id/createteamLayout2"
android:id="#+id/invitebtn"
android:onClick="onInviteMember"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:id="#+id/Donebtn"
android:onClick="onDonebtn"
android:layout_gravity="right"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"
android:id="#+id/Exitbtn"
android:onClick="onExitbtn"
android:layout_weight="1"/>
</LinearLayout>

how to set one linear layout below another linear layout in android

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation=""
android:layout_marginTop="40dp" >
<LinearLayout
android:id="#+id/imagecontainlayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Status:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_weight=".75" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="295dp"
android:layout_height="44dp"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Status:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
Here is my Xml am trying to set imagecontainlayout linear layout to another linear layout containing another linear layout with some gap but i dont know where am doing mistake in my code my current screen is coming like this .
my current screen is coming like this while i want there first layout below another layout with some gap please help me where am doing mistake.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/round_bg"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:singleLine="true"
android:text="Step:"
android:textColor="#0060a4"
android:textSize="15dp" />
<TextView
android:id="#+id/step"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
android:textColor="#0060a4"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
use this code it will Help u .

Android - EditText's hint changes View/Layout's size

I have a LinearLayout consisting of 3 LinearLayout's consisting of 2 TextView's and an EditText. When I add a hint to the third EditText I end up with a lot of whitespace between the 2nd and 3rd TextViews and also after the 3rd.
Code and images are below. What could be causing this?
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="#+id/self"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Name"
android:padding="5dp"
android:id="#+id/self_name_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="#+id/self_name_edit"
android:inputType="text"
android:hint="#string/enter_name"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/address"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Address"
android:padding="5dp"
android:id="#+id/self_address_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/self_address_edit"
android:visibility="gone"
android:inputType="text"
android:hint="#string/enter_address"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/phone"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:autoLink="all"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Phone"
android:padding="5dp"
android:id="#+id/self_phone_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/self_phone_edit"
android:phoneNumber="true"
android:hint="#string/enter_phone"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="#string/edit"
android:id="#+id/edit_self_button"
android:onClick="toggleSelfEdit"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="#string/update"
android:id="#+id/update_self_button"
android:visibility="gone"
/>
</LinearLayout>
Without hint:
With hint:
I think you forgot writing the android:visibility="gone" at the third edittext. I tried your xml and when I put visibility="gone" inside the edittext your xml looks like the first screenshot :)

Android: Views in ScrollView doesn't appear past empty LinearLayout

On Android 4, I have a simple ScrollView which presents a form to fill in. Inside the view I have a number of buttons, then this Layout,
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layoutImages" />
then more buttons. The layout always stops rendering at the LinearLayout. If I move the layout down the list of views, all views above it appear. I can reference the other layouts in code nicely so they are there, just not visible.
Do I need to do something to the LinearLayout to prevent it from stopping the rendering of all the subsequent views?
For reference, here's the full layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="#+id/scrView">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_selector">
<Button
android:text="Call Crime Stoppers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnCall"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:layout_marginTop="5dp"
android:background="#drawable/blue_button_selector"
android:textSize="25dp"
android:textColor="#color/white"
android:drawableLeft="#drawable/phone_element" />
<TextView
android:text="About the Incident:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/lblDescriptionTop"
android:layout_marginTop="15dp" />
<Button
android:text="Take a Picture"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnPicture"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:layout_marginTop="5dp"
android:background="#drawable/blue_button_selector"
android:textSize="25dp"
android:textColor="#color/white"
android:drawableLeft="#drawable/icon_camera" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layoutImages" />
<Button
android:text="Location Type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnLocationType"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:layout_marginTop="5dp"
android:background="#drawable/blue_button_selector"
android:textSize="25dp"
android:textColor="#color/white" />
<Button
android:text="Nature of the Incident"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnNature"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:background="#drawable/blue_button_selector"
android:textSize="25dp"
android:textColor="#color/white"
android:layout_marginTop="5dp" />
<TextView
android:text="Please Describe:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/lblDescription"
android:layout_marginTop="15dp" />
<EditText
android:inputType="textMultiLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/txtDescription"
android:minHeight="150dp"
android:maxHeight="150dp"
android:layout_marginTop="5dp"
android:minWidth="150dp"
android:maxWidth="150dp" />
<TextView
android:text="Optional Contact Info:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:layout_marginTop="15dp" />
<CheckBox
android:text="Use Phone Number?"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/chkPhone" />
<EditText
android:inputType="phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/editPhone"
android:hint="Phone Number" />
<CheckBox
android:text="Use Email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/chkEmail" />
<EditText
android:inputType="phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/editEmail"
android:hint="Email" />
<Button
android:text="Send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/btnSend"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:background="#drawable/blue_button_selector"
android:textSize="25dp"
android:textColor="#color/white"
android:layout_marginTop="15dp" />
</LinearLayout>
</ScrollView>
That is because you have your layout_height set to "fill_parent" so it's taking up the rest of the space below that. That's why it works when it's at the bottom, but not in the middle.
Try either changing it to "wrap_content" or using a RelativeLayout.

How can I place two TextView on a same line, in a vertical layout

I am trying to display an ImageView with 4 textView. "Title" "times" "age" and "informations". All of them are in global horizontal layout. And the 4 textView are in a vertical layout. The thing is that I want to have "times" and "age" one the same line. But it can't be with a vertical layout.
Here is my xml 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="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titre"
android:textSize="8sp"
android:textStyle="bold" />
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="age" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="age" />
<TextView
android:id="#+id/information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textSize="8sp"
android:text="phrase" />
</LinearLayout>
Thanks
Here you go
<?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="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titre"
android:textSize="8sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time"
android:textSize="8sp" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="age"
android:textSize="8sp" />
</LinearLayout>
<TextView
android:id="#+id/information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="phrase"
android:textSize="8sp" />
</LinearLayout>
Put LinearLayout as a parent to both textviews and set orientation of that LinearLayout as Horizontal..
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="time" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="age" />
<LinearLayout/>
as I told there is one more approach using Relative layout the second one
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="8sp"
android:textStyle="bold"
android:layout_alignParentTop="true" />
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="time"
android:layout_below="#id/title" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="8sp"
android:text="age"
android:layout_below="#id/title"
android:layout_toRightOf="#id/time" />
<TextView
android:id="#+id/information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textSize="8sp"
android:text="phrase"
android:layout_below="#id/time" />
Use the Graphical Layout, and place the age and the time fiels on the same ligne..much easier

Categories

Resources