Android layout not as expected - android

So I am a beginner at layouts in Android and I am learning RelativeLayout. I am attempting to make the following:
However, all I get in my virtual device is the name field taking up 100% of the space (width and height).
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/root">
<EditText android:id="#+id/name"
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint = "Name"/>
<EditText android:id="#+id/phone"
android:layout_below="#id/name"
android:layout_alignParentRight="true"
android:layout_weight="0.4"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:hint="Phone" />
<EditText android:id="#+id/email"
android:layout_below="#id/phone"
android:layout_alignParentRight="true"
android:layout_weight="0.4"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:hint="Email" />
<EditText android:id="#+id/dob"
android:layout_below="#id/email"
android:layout_alignParentRight="true"
android:layout_weight="0.4"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:hint="D.O.B." />
<EditText android:id="#+id/address"
android:layout_below="#id/phone"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/dob"
android:layout_weight="0.6"
android:layout_height="0dp"
android:layout_width="match_parent"
android:hint="Address" />
<Button android:id="#+id/submit"
android:layout_weight="1.0"
android:layout_below="#id/address"
android:layout_height="match_parent"
android:layout_width="0dp"
android:text="Submit"/>
</RelativeLayout>
What is going wrong?

Here is the xml for your output.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="Name" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true
android:layout_weight="-10"
android:hint="Phone" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/phone"
android:layout_weight="0.4"
android:hint="Email" />
<EditText
android:id="#+id/dob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/email"
android:layout_weight="0.4"
android:hint="D.O.B." />
<EditText
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/phone"
android:layout_toLeftOf="#id/dob"
android:layout_weight="0.6"
android:hint="Address" />
</RelativeLayout>
<Button
android:id="#+id/submit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Submit" />
</LinearLayout>

Change the layout_height for the name element to:
android:layout_height="wrap_content"

Change your Layout XML to the above:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:hint="Name" />
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/name"
android:orientation="horizontal"
android:layout_marginBottom="60dp"
android:weightSum="1" >
<EditText
android:id="#+id/address"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:hint="Address" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.4"
android:weightSum="3" >
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Phone" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="Email" />
<EditText
android:id="#+id/dob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:hint="D.O.B." />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:text="Submit" />
</RelativeLayout>
Hope that helps:)

Related

ScrollView Open my edittexts and work only if open

i have a bad problem. i need to use a scrollview into my app, but this on start open editext Keyboard.
If Keyboard is open, scrollview work, but if i close the keybord scroll not work.
How to resolve this ploblem?
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/taglio"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:text="+"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/piutagliodonna"
android:textStyle="normal|bold"
android:layout_weight="1"
android:alpha="0.70"
/>
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/editTexttagliodonna"
android:hint="0"
android:textAlignment="center"
android:layout_weight="1"/>
<Button
android:text="-"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/menotagliodonna"
android:layout_weight="1"
android:textStyle="normal|bold"
android:alpha="0.70"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Try this, but change and add RelativeLayout to LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="pl.com.qubuss.test.RegisterActivity">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/nameET"
android:layout_marginTop="20dp"
android:inputType="textPersonName"
android:hint="#string/nameTextHint"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:width="200dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/surnameET"
android:layout_below="#+id/nameET"
android:layout_alignLeft="#+id/nameET"
android:layout_alignStart="#+id/nameET"
android:layout_marginTop="20dp"
android:width="200dp"
android:hint="#string/surnameTextHint" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/emailET"
android:hint="#string/emailTextHint"
android:width="200dp"
android:layout_below="#+id/surnameET"
android:layout_alignLeft="#+id/surnameET"
android:layout_alignStart="#+id/surnameET"
android:layout_marginTop="20dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/username_registerET"
android:layout_below="#+id/emailET"
android:layout_alignLeft="#+id/emailET"
android:layout_alignStart="#+id/emailET"
android:layout_marginTop="20dp"
android:width="200dp"
android:hint="#string/usernameTextHint" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/password_registerET"
android:layout_below="#+id/username_registerET"
android:layout_alignLeft="#+id/username_registerET"
android:layout_alignStart="#+id/username_registerET"
android:layout_marginTop="20dp"
android:hint="#string/passwordTextHint" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/registerButton"
android:id="#+id/registerButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="23dp"
android:layout_below="#+id/conPasswor_registerET"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/conPasswor_registerET"
android:layout_marginTop="20dp"
android:layout_below="#+id/password_registerET"
android:layout_alignLeft="#+id/password_registerET"
android:layout_alignStart="#+id/password_registerET"
android:hint="#string/conPasswordTextHint" />
</RelativeLayout>
</ScrollView>

LinearLayout not work with RelativeLayout

I want to create following layout.
--------------------------------
Title
Summary Info
[Get Direction][Call][More Info]
--------------------------------
I code following layout but buttons not showing. I have no idea why LinearLayout works like FrameLayout so the RelativeLayout hides buttons. Did I miss something here?
I am using support library 22.1
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="#dimen/location_card_height">
<ImageView android:id="#+id/cardImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<TextView android:id="#+id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:singleLine="true"
android:hint="Title" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/title">
<TextView android:id="#+id/info"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:hint="Info"
android:layout_alignParentRight="true"
android:ellipsize="end" />
<TextView android:id="#+id/summary"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:hint="Summary"
android:layout_toLeftOf="#id/info"
android:ellipsize="end" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/panelAction"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btnDirection"
android:text="#string/get_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btnCall"
android:text="#string/label_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btnMoreInfo"
android:text="#string/more_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
Your relative layout has been set to match_parent for it height!
change it to wrap_content
that should help you
or put it in a LinearLayout
something like this :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="#dimen/location_card_height">
<ImageView android:id="#+id/cardImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="vertical" >
<RelativeLayout
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<TextView android:id="#+id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:singleLine="true"
android:hint="Title" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/title">
<TextView android:id="#+id/info"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:hint="Info"
android:layout_alignParentRight="true"
android:ellipsize="end" />
<TextView android:id="#+id/summary"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAppearance="?android:attr/textAppearance"
android:singleLine="true"
android:hint="Summary"
android:layout_toLeftOf="#id/info"
android:ellipsize="end" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/panelAction"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<Button
android:id="#+id/btnDirection"
android:text="#string/get_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btnCall"
android:text="#string/label_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btnMoreInfo"
android:text="#string/more_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
If you are fine With Linearlayout Then Here is Your XML file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ImageView
android:id="#+id/cardImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="center"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:singleLine="true"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/summary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/info"
android:layout_weight="1"
android:ellipsize="end"
android:hint="Summary"
android:singleLine="true"
android:text="Summary"
android:textAppearance="?android:attr/textAppearance" />
<TextView
android:id="#+id/info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="right"
android:hint="Info"
android:singleLine="true"
android:text="Info"
android:textAppearance="?android:attr/textAppearance" />
</TableRow>
</LinearLayout>
<LinearLayout
android:id="#+id/panelAction"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="bottom" >
<Button
android:id="#+id/btnDirection"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Get_direction" />
<Button
android:id="#+id/btnCall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="call" />
<Button
android:id="#+id/btnMoreInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="more_info" />
</LinearLayout>

How to design a simple form in android?

I need to create a simple form in which I give a description like "Name" and give a textbox below it to give the name. But, I am not able to achieve using this code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1.8"
android:text="Name *"
android:textSize="20dp" />
<EditText
android:id="#+id/name_edt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1.8"
android:text="Training Types *"
android:textSize="20dp" />
<EditText
android:id="#+id/trainingtypes_edt"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</LinearLayout>
try below code :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Field1"
/>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Field2"
/>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Field3"
/>
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
try this. when orientation is vertical u should give height to 0dp, and when orientation is horizontal u should give width as 0dp if u r specifying weight
<?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" >
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1.8"
android:text="Name *"
android:textSize="20dp" />
<EditText
android:id="#+id/name_edt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1.8"
android:text="Training Types *"
android:textSize="20dp" />
<EditText
android:id="#+id/trainingtypes_edt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name *" />
<EditText
android:id="#+id/name_edt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Training Types *" />
<EditText
android:id="#+id/trainingtypes_edt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" />
</LinearLayout>
Try this code it working properly
<?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" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Name *"
android:textSize="20sp" />
<EditText
android:id="#+id/name_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Training Types *"
android:textSize="20sp" />
<EditText
android:id="#+id/trainingtypes_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Hope it helps ... :)
Try this code. I did not change much. I just correct some codes. Try to find those and enjoy :)
<?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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Name *"
android:textSize="20sp" />
<EditText
android:id="#+id/name_edt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:hint="Name"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Training Types *"
android:textSize="20sp" />
<EditText
android:id="#+id/trainingtypes_edt"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="Training types"/>
</LinearLayout>
Hope this help you :)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.Afieldinc.registeruser.MainActivity$PlaceholderFragment" >
<EditText
android:id="#+id/UserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:ems="10"
android:hint="User Name"
android:inputType="text" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/UserName"
android:layout_alignLeft="#+id/UserName"
android:layout_marginBottom="35dp"
android:text="Name" />
<LinearLayout android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/UserName"
android:layout_below="#+id/PassWord" android:layout_marginLeft="16dp">
<Button
android:id="#+id/SignIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In" />
<Button android:id="#+id/SignUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign Up"/>
</LinearLayout>
<EditText
android:id="#+id/PassWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/UserName"
android:layout_below="#+id/UserName"
android:layout_marginTop="44dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/PassWord"
android:layout_below="#+id/UserName"
android:layout_marginTop="19dp"
android:text="Password" />
</RelativeLayout>
try this one out i hope it will help

How to create layout for registration mobile number

http://snag.gy/0kz5e.jpg please look this Image I have to create layout but
I am unable to do this there is some Problem with android control set on particular.
I am able to display controls in android:gravity bottom but my controls is not fix like image please check what I am missing where am doing wrong .
here is my Xml file code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/registraionimage" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="132dp"
android:layout_gravity="bottom"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="49dp"
android:entries="#array/country_arrays"
android:prompt="#string/country_prompt" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/editText1"
android:layout_width="94dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="Code" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="phone"
android:text="Phone" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/layout1"
android:text="Next"
android:textColor="#0066FF"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
Can you just try below code, I replace FrameLayout to RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:background="#android:color/transparent"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<EditText
android:id="#+id/editText1"
android:layout_width="94dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="Code" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone"
android:text="Phone" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Next"
android:textColor="#0066FF"
android:textStyle="bold" />
</LinearLayout>

When focus on the edite text resize layout

when i press on the edit text the layout become re-size. What i want is not to change the layout size when i press on the keyboard
I tried
android:windowSoftInputMode="stateVisible|adjustPan"
Refer from below link
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Don't make any difference
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:background="#0486CC" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".34"
android:src="#drawable/logo" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".32" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".16"
android:background="#drawable/newmenu"
android:onClick="MenuStaffBtnClick" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".18"
android:background="#drawable/menu_sync"
android:onClick="MenuSynBtnClick" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".2" >
<EditText
android:id="#+id/etNamecheck"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight=".6"
android:ems="10"
android:hint="Name" />
<RadioGroup
android:id="#+id/rgSearch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".4"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rbID"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/rbName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".7"
android:orientation="vertical" >
<ListView
android:id="#+id/LVitems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#bbbbbb"
android:dividerHeight="5dp" >
</ListView>
</LinearLayout>
try this layout code and add android:windowSoftInputMode="stateVisible|adjustPan" in android manifest file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:id="#+id/scrolllayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SignIn"
android:textColor="#000000"
android:layout_marginTop="10dp"
android:textSize="20dp"
/>
<EditText
android:id="#+id/userid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:hint="type username" />
<EditText
android:id="#+id/passwordid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="type password"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#000000"
android:inputType="textPassword" />
<Button
android:id="#+id/loginid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#color/list_item_title"
android:text="Signin"
android:textSize="20dp"
android:background="#drawable/btngradient"
/>
<Button android:id="#+id/registerid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:textSize="20dp"
android:text=" Register"
android:gravity="center"
android:background="#drawable/btngradient"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:textColor="#FFFFFF"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

Categories

Resources