I'm attempting to set my background image however it will not seem to fill to the edge of the screen and I'm not sure why. I'm pretty sure those two parameters have worked for me in the past.
Any suggestions are appreciated.
http://i.stack.imgur.com/WM5OJ.png
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
This is simple. first see this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
Based on your XML you set a margin on your relative layout with 20dp left and right then added a linear layout with background image that match the parent wherein the parent is the relative layout. Remove the margin of the relative layout then it will fit the screen then all of the content that needs to have a margin of 20dp left and right must be inside the linear layout to solve this.
use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:background="#drawable/ui2"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
</LinearLayout>
Use padding instead of margin on your RelativeLayout as follows
android:layout_paddingLeft="20dp"
android:layout_paddingRight="20dp"
Hope this helps.
replace this
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
in your Layout to
android:paddingLeft="20dp"
android:paddingRight="20dp"
Hope this helps
Related
I am facing this strange issue with my layout that too only in htc devices.
This is how the original layout looks
This is how it looks in device
This is the xml code for the following
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/topRl"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#color/white">
<Button
android:id="#+id/backBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:background="#drawable/back_arrow" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="#string/register_heading"
android:textColor="#color/black"
android:textSize="#dimen/text_size_for_heading" />
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="3px"
android:background="#drawable/shadow_down"
/>
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/mainLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<Button
android:id="#+id/registerWithFacebookBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20px"
android:background="#drawable/blue_dark_btn_selector"
android:text="#string/register_with_facebook"
android:textColor="#drawable/white_color_selector"
android:textSize="#dimen/text_18sp" />
<LinearLayout
android:id="#+id/etLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<EditText
android:id="#+id/firstNameEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/first_name"
android:imeOptions="actionNext"
android:inputType="textPersonName|textNoSuggestions|textCapSentences"
android:maxLines="1"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/lastNameEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/last_name"
android:inputType="textPersonName|textNoSuggestions|textCapSentences"
android:maxLines="1"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<!--<RelativeLayout
android:id="#+id/rlCountryCode"
android:layout_width="150px"
android:layout_height="#dimen/edit_text_height"
android:layout_alignParentLeft="true">
<TextView
android:id="#+id/tvCountryCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5px"
android:background="#drawable/edit_text_bg"
android:gravity="center"
android:paddingLeft="20px"
android:paddingRight="20px"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textSize="#dimen/text_size_edit_text" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="14px"
android:layout_height="11px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10px"
android:background="#drawable/down_arrow_btn_selector"
android:clickable="false"
android:duplicateParentState="true" />
</RelativeLayout>-->
<EditText
android:id="#+id/phoneNoEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5px"
android:layout_toRightOf="#+id/rlCountryCode"
android:digits="0123456789"
android:hint="#string/phone_number"
android:inputType="phone|textNoSuggestions"
android:maxLength="10"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/emailIdEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/email_id"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/passwordEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/password"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/confirmPasswordEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/confirm_password"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/aboutUsET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/hear_about_us"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="3dp"
android:layout_marginLeft="20px"
android:layout_marginRight="20px"
android:paddingTop="5dp">
<CheckBox
android:id="#+id/agree_chk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/check_box_selector"
android:padding="5dp"
android:text="#string/agree_text"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/terms_of_use_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/terms_of_use"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/and_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="and"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
<TextView
android:id="#+id/privacy_policy_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="40dp"
android:text="#string/privacy_policy"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/signUpBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/btn_corner_margin"
android:layout_marginTop="#dimen/btn_corner_margin"
android:background="#drawable/blue_dark_btn_selector"
android:text="#string/register"
android:textColor="#drawable/btn_text_color_selector"
android:textSize="#dimen/button_text_size"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I tried creating different layout according to different screen sizes but it still looks the same with no effect at all. I also have proper drawables in different folders.
I just put a linear layout inside a scrollview dont know why its not working.
When the keyboard is open the scrollbar is not showing at all. When i move one text box to another there is a submit button which is not show when i run on small size devices.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/layoutPopUp"
android:layout_width="match_parent"
android:layout_height="79dp"
android:background="#F57F20"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:visibility="visible">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/backlayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal">
<ImageButton
android:id="#+id/btnBackbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/back"
android:visibility="visible" />
<TextView
android:id="#+id/textBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:gravity="center"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/textTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.6"
android:gravity="center"
android:text="Contact Us"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imagePopUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/menu"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Phone No."
android:inputType="phone"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:hint="Comments"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</LinearLayout>
try to put scrollview inside another linear layout and try
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/parentLin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="//define in dp"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColorHint="#2b2b2b"
android:textColor="#2b2b2b"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:textColor="#2b2b2b"
android:hint="Phone No."
android:inputType="phone"
android:textColorHint="#2b2b2b"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColor="#2b2b2b"
android:ems="10"
android:textColorHint="#2b2b2b"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:textColor="#2b2b2b"
android:hint="Comments"
android:textColorHint="#2b2b2b"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
and You have to specify the following line of code in the manifest file with your activity
android:windowSoftInputMode="adjustResize"
try This.. on your activity / fragment
getActivity().getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
I am implementing an registration page in which i want to implement the Scrollview. please help. Android Relative Layout Align Center i have tried this but still not getting it.
Registration.Xml
<?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:weightSum="1"
android:background="#f33a58"
android:baselineAligned="false"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registration Page"
android:id="#+id/logo"
android:layout_marginTop="40dp"
android:textSize="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:textColor="#ffffff" />
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:ems="10"
android:hint="Username"
android:layout_gravity="center"
android:textColorHint="#ffffff"
android:backgroundTint="#ffffff"
style="#style/AppTheme.PopupOverlay" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Password"
android:password="true"
android:inputType="textPassword"
android:textColorHint="#ffffff"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColorHint="#ffffff"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff">
</EditText>
<EditText
android:id="#+id/phone_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Phone Number"
android:inputType="phone"
android:layout_marginTop="20dp"
android:maxLength="10"
android:digits="0123456789"
android:textColorHint="#ffffff"
android:backgroundTint="#ffffff" />
<Button
android:id="#+id/register"
android:layout_width="134dp"
android:layout_height="wrap_content"
android:text="Register"
android:layout_marginTop="20dp"
android:background="#drawable/button"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="40dp"
android:text="Registration Page"
android:textColor="#ffffff"
android:textSize="35dp" />
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_gravity="center"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Username"
style="#style/AppTheme.PopupOverlay"
android:textColorHint="#ffffff" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:password="true"
android:textColorHint="#ffffff" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColorHint="#ffffff" >
</EditText>
<EditText
android:id="#+id/phone_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:digits="0123456789"
android:ems="10"
android:hint="Phone Number"
android:inputType="phone"
android:maxLength="10"
android:textColorHint="#ffffff" />
<Button
android:id="#+id/register"
android:layout_width="134dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/button"
android:text="Register" />
</LinearLayout>
</ScrollView>
I'm trying to make a form that has many textView and editText controls so I tried using scrollview because the screen won't be able to display all of them.
But when I added to a certain set of textview and scrollview, the next one appears on the top side of the screen instead of below the previous set.
Below is my xml, Please help!
XML FILE :
<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=".InsertJob" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="358dp"
android:orientation="vertical" >
<TextView
android:id="#+id/JobNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="#string/name" />
<EditText
android:id="#+id/JobNameET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/JobNameTV"
android:layout_alignBottom="#+id/JobNameTV"
android:layout_marginLeft="70dp"
android:layout_marginRight="20dp"
android:layout_toRightOf="#+id/JobNameTV"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/JobDateTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobNameTV"
android:layout_below="#+id/JobNameET"
android:layout_marginTop="25dp"
android:text="#string/date" />
<EditText
android:id="#+id/JobDateET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/JobDateTV"
android:layout_alignBottom="#+id/JobDateTV"
android:layout_alignLeft="#+id/JobNameET"
android:layout_marginRight="20dp"
android:ems="10"
android:hint="#string/date_example"
android:inputType="date" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/JobTimeStartTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobDateTV"
android:layout_below="#+id/JobDateTV"
android:layout_marginTop="25dp"
android:text="Jam Mulai" />
<EditText
android:id="#+id/JobTimeStartET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/JobTimeStartTV"
android:layout_alignBottom="#+id/JobTimeStartTV"
android:layout_alignLeft="#+id/JobDateET"
android:layout_marginRight="20dp"
android:ems="10"
android:hint="#string/timeexample"
android:inputType="time" />
<TextView
android:id="#+id/JobTimeEndTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobDateTV"
android:layout_below="#+id/JobTimeStartTV"
android:layout_marginTop="25dp"
android:text="Jam Selesai" />
<EditText
android:id="#+id/JobTimeEndET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/JobTimeEndTV"
android:layout_alignBottom="#+id/JobTimeEndTV"
android:layout_alignLeft="#+id/JobDateET"
android:layout_marginRight="20dp"
android:ems="10"
android:hint="#string/timeexample"
android:inputType="time" />
<TextView
android:id="#+id/JobPlaceTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobTimeEndTV"
android:layout_below="#+id/JobTimeEndET"
android:layout_marginTop="25dp"
android:text="#string/place" />
<EditText
android:id="#+id/JobPlaceET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/JobPlaceTV"
android:layout_alignBottom="#+id/JobPlaceTV"
android:layout_alignLeft="#+id/JobTimeEndET"
android:layout_marginRight="20dp"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/JobDetailTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobPlaceTV"
android:layout_below="#+id/JobPlaceET"
android:layout_marginTop="40dp"
android:text="Detail" />
<EditText
android:id="#+id/JobDetailET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobPlaceET"
android:layout_alignBaseline="#+id/JobDetailTV"
android:layout_marginRight="20dp"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/SongListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobDetailTV"
android:layout_below="#+id/JobDetailET"
android:layout_marginTop="20dp"
android:text="Lagu 1" />
<EditText
android:id="#+id/SongListET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/JobDetailET"
android:layout_alignBaseline="#+id/SongListTV"
android:ems="10"
android:inputType="text" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/LogoutBtn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/logout"
android:onClick="logout" />
<Button
android:id="#+id/ConfirmBtn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignBottom="#+id/LogoutBtn"
android:layout_marginLeft="20dp"
android:background="#drawable/confirm" />
</RelativeLayout>
// Try this way,hope this will help you to solve your problem.
<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=".InsertJob" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="358dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:id="#+id/JobNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="#string/name" />
<EditText
android:id="#+id/JobNameET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/JobNameTV"
android:layout_marginLeft="70dp"
android:layout_toRightOf="#id/JobNameTV"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/JobDateTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobNameET"
android:layout_marginTop="25dp"
android:text="#string/date" />
<EditText
android:id="#+id/JobDateET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobNameET"
android:layout_alignBaseline="#id/JobDateTV"
android:layout_toRightOf="#id/JobDateTV"
android:ems="10"
android:hint="#string/date_example"
android:inputType="date" >
</EditText>
<TextView
android:id="#+id/JobTimeStartTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobDateTV"
android:layout_marginTop="25dp"
android:text="Jam Mulai" />
<EditText
android:id="#+id/JobTimeStartET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobDateET"
android:layout_alignBaseline="#id/JobTimeStartTV"
android:layout_toRightOf="#id/JobTimeStartTV"
android:ems="10"
android:hint="#string/timeexample"
android:inputType="time" />
<TextView
android:id="#+id/JobTimeEndTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobTimeStartTV"
android:layout_marginTop="25dp"
android:text="Jam Selesai" />
<EditText
android:id="#+id/JobTimeEndET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobTimeStartET"
android:layout_alignBaseline="#id/JobTimeEndTV"
android:layout_toRightOf="#id/JobTimeEndTV"
android:ems="10"
android:hint="#string/timeexample"
android:inputType="time" />
<TextView
android:id="#+id/JobPlaceTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobTimeEndTV"
android:layout_marginTop="25dp"
android:text="#string/place" />
<EditText
android:id="#+id/JobPlaceET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobTimeEndET"
android:layout_alignBaseline="#id/JobPlaceTV"
android:layout_toRightOf="#id/JobPlaceTV"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/JobDetailTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobPlaceTV"
android:layout_marginTop="40dp"
android:text="Detail" />
<EditText
android:id="#+id/JobDetailET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobPlaceET"
android:layout_alignBaseline="#id/JobDetailTV"
android:layout_toRightOf="#id/JobDetailTV"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/SongListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/JobDetailTV"
android:layout_marginTop="20dp"
android:text="Lagu 1" />
<EditText
android:id="#+id/SongListET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/JobDetailET"
android:layout_alignBaseline="#id/SongListTV"
android:layout_toRightOf="#id/SongListTV"
android:ems="10"
android:inputType="text" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/LogoutBtn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/logout"
android:onClick="logout" />
<Button
android:id="#+id/ConfirmBtn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignBottom="#+id/LogoutBtn"
android:layout_marginLeft="20dp"
android:background="#drawable/confirm" />
</RelativeLayout>
EditText JobDateET is missing attribute "android:layout_layout_below="#+id/JobDateTV"
EditText JobTimeStartET is missing attribute "android:layout_layout_below="#+id/JobTimeStartTV"
EditText JobTimeStartET is missing attribute "android:layout_layout_below="#+id/JobTimeStartTV"
Try this.......
<TextView
android:id="#+id/SongListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/JobDetailTV"
android:layout_marginTop="20dp"
android:text="Lagu 1"/>
On this screenshot:
I am looking for the solution to make the UI more decent. I like the blue line for the input box but it only show either User Name or Password only. What is the simplest way to let the 2 blue line appear below User Name and Password in order?
Cheers
Here's what i have tried so far
<RelativeLayout 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:background="#color/myBackground"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/voicemeno" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/imageView1"
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/userNameInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/userName"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/userNameInput"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/passwordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/password"
android:ems="10"
android:inputType="textPassword"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
</RelativeLayout>
Edit:
<RelativeLayout 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:background="#color/myBackground"
tools:context=".MainActivity"
android:selectAllOnFocus="true">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/voicemeno" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/imageView1"
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/userNameInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/userName"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/userNameInput"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/passwordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/password"
android:ems="10"
android:inputType="textPassword"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
</RelativeLayout>
you can use a TextView followed by a EditText view for each of the filds(username,password) you want.