HI,
In my android app,the emulator screen is rotating in landscape i didn't get the full view of a registration form. But in portrait mode it works perfectly. Please Look through it.Thanks in Advance.
activity_main
<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"
android:padding="10dp"
android:weightSum="1">
<TextView
android:text="Soil Test Based Nutrient Recommendations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAlignment="center"
android:id="#+id/title"
android:layout_weight="0.03" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="#000000"
android:text="Crop"/>
<Spinner android:id="#+id/spinFood"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="State"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:id="#+id/textView" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner" />
<TextView
android:text="Category"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner2" />
<TextView
android:text="Soil_Texture"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner3" />
<TextView
android:text="pH"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView4" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText" />
<TextView
android:text="Available Phosphorus"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView5" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText2" />
<TextView
android:text="Available Pottassium"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView6" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText3" />
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button" />
</LinearLayout>
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:weightSum="1">
<TextView
android:text="Soil Test Based Nutrient Recommendations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAlignment="center"
android:id="#+id/title"
android:layout_weight="0.03" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="#000000"
android:text="Crop"/>
<Spinner android:id="#+id/spinFood"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="State"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:id="#+id/textView" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner" />
<TextView
android:text="Category"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner2" />
<TextView
android:text="Soil_Texture"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner3" />
<TextView
android:text="pH"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView4" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText" />
<TextView
android:text="Available Phosphorus"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView5" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText2" />
<TextView
android:text="Available Pottassium"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView6" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText3" />
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/button" />
</LinearLayout>
</ScrollView>
Just wrap into ScrollView to Main LinearLayout
Add android:screenOrientation="portrait" to the activity you want to disable landscape mode.
Related
I have been trying to develop a form in android studio, and I am quite new to xml so not sure what I am doing wrong. Hopefully you can see from below, the preview shows as the boxes taking up basically the full page, however when I render it in a phone it only takes up half the page. Xml code is also below - any ideas would be greatly appreciated? Thanks
XML preview:
Rendered view:
XML Code:
<?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"
android:id="#+id/RelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:theme="#style/AppTheme">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/activity_horizontal_margin"
android:orientation="vertical">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Date"
android:inputType="date" />
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Time"
android:inputType="time" />
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Show Notes at appointment" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Missed Appointment" />
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="#+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save Notes" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<?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:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="60dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:id="#+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Date"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:id="#+id/Time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Time"
android:inputType="time" />
</LinearLayout>
<LinearLayout
android:id="#+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:id="#+id/testernotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:id="#+id/checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:text="CheckBox" />
</LinearLayout>
<LinearLayout
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="CheckBox" />
</LinearLayout>
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="#+id/button3"
android:text="button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</ScrollView>
please try this xml
layout_weight and its usages was wrong in your xml ,while using layout_weight you have use android:layout_width = "0dp" as per the orientation,
for more info refer
[https://developer.android.com/guide/topics/ui/layout/linear.html][1]
https://blog.stylingandroid.com/layout-weights-part-1/
What does android:layout_weight mean?
much easier implementation
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_margin="#dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Date"
android:inputType="date" />
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Time"
android:inputType="time" />
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CheckBox" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CheckBox" />
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="#+id/button3"
android:text="button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</ScrollView>
MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.
Replace this:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
With:
android:layout_width="match_parent"
android:layout_height="wrap_content"
into your LinearLayout.
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 am creating a registration screen strangely I am facing an issue with padding a layout which has sign up text.
I would like to align it according to text box shown in the screen shot below. I am not sure why this giving me this strange issue?
Below is the code I have tried:
<?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:background="#color/backgroundcolor"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="#string/signUp"
android:textColor="#000000"
android:textSize="20sp" />
<LinearLayout
android:id="#+id/linearlayout1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/header"
android:padding="10dp" >
<EditText
android:id="#+id/namefEDIT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/textbox"
android:hint="#string/fname"
android:padding="5dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/fnamelinearlayout"
android:padding="10dp" >
<EditText
android:id="#+id/namelEDIT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/textbox"
android:hint="#string/lname"
android:padding="5dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout3"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/lnamelinearlayout"
android:padding="10dp" >
<EditText
android:id="#+id/numberEDIT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/textbox"
android:hint="#string/mobilenumber"
android:inputType="numberSigned"
android:padding="5dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout4"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/mobilelinearlayout"
android:padding="10dp" >
<EditText
android:id="#+id/pEDIT"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/textbox"
android:hint="#string/password"
android:inputType="textPassword"
android:padding="5dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout5"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/passwordlinearlayout"
android:layout_marginTop="15dp"
android:background="#drawable/button_selector"
android:orientation="vertical" >
<TextView
android:id="#+id/textEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="10dp"
android:textSize="20sp"
android:text="#string/signText"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Below is the screen shot:
This layout should do the same:
<TextView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="#string/signUp"
android:textColor="#000000"
android:textSize="20sp" />
<EditText
android:id="#+id/namefEDIT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/textbox"
android:hint="#string/fname"
android:padding="5dp"
android:layout_margin="10dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
<EditText
android:id="#+id/namelEDIT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/textbox"
android:hint="#string/lname"
android:padding="5dp"
android:layout_margin="10dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
<EditText
android:id="#+id/numberEDIT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/textbox"
android:hint="#string/mobilenumber"
android:inputType="numberSigned"
android:padding="5dp"
android:layout_margin="10dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
<EditText
android:id="#+id/pEDIT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/textbox"
android:hint="#string/password"
android:inputType="textPassword"
android:padding="5dp"
android:layout_margin="10dp"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="20sp" />
<TextView
android:id="#+id/textEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="10dp"
android:layout_margin="10dp"
android:textSize="20sp"
android:text="#string/signText"
android:textColor="#000000" />
</LinearLayout>
I have the following xml layout:
<?xml version="1.0" encoding="utf-8"?>
<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">
<TextView
android:id="#+id/textHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="10dp"
android:textStyle="bold"
android:text="#string/form_header"
android:textSize="10pt" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/textHeader">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dp"
android:textColor="#color/red"
android:text="#string/form_comp"
android:textSize="7pt" />
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textComp" >
<TextView
android:id="#+id/textTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_title"
android:textSize="7pt" />
<Spinner
android:id="#+id/title_spinner"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/textTitle"
android:focusable="true"
android:padding="10dip" />
<TextView
android:id="#+id/textFname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textTitle"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_fname"
android:textSize="7pt" />
<EditText
android:id="#+id/editFname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_below="#+id/textTitle"
android:layout_toRightOf="#id/textFname"
android:ems="10"
android:maxLength="15" />
<TextView
android:id="#+id/textLname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textFname"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_lname"
android:textSize="7pt" />
<EditText
android:id="#+id/editLname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_below="#+id/textFname"
android:layout_toRightOf="#id/textLname"
android:ems="10"
android:maxLength="15" />
<TextView
android:id="#+id/textTel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textLname"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_tel"
android:textSize="7pt" />
<EditText
android:id="#+id/editTel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_below="#+id/textLname"
android:layout_toRightOf="#id/textTel"
android:ems="10"
android:maxLength="15" />
<TextView
android:id="#+id/textEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textTel"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_email"
android:textSize="7pt" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:layout_below="#+id/textTel"
android:layout_toRightOf="#id/textEmail"
android:ems="10"
android:maxLength="25" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1" >
<TextView
android:id="#+id/textDep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_dep"
android:textSize="7pt" />
<EditText
android:id="#+id/editDep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_toRightOf="#id/textDep"
android:ems="10"
android:maxLength="25" />
<TextView
android:id="#+id/textDest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_dest"
android:layout_below="#+id/textDep"
android:textSize="7pt" />
<EditText
android:id="#+id/editDest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:layout_toRightOf="#id/textDest"
android:layout_below="#+id/textDep"
android:ems="10"
android:maxLength="25" />
<TextView
android:id="#+id/textNpersons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_npersons"
android:layout_below="#+id/editDest"
android:textSize="7pt" />
<EditText
android:id="#+id/editNpersons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_toRightOf="#id/textNpersons"
android:layout_below="#+id/editDest"
android:ems="10"
android:maxLength="3" />
<TextView
android:id="#+id/textDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_date"
android:layout_below="#+id/textNpersons"
android:textSize="7pt" />
<Spinner
android:id="#+id/spYear"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_below="#+id/textNpersons"
android:layout_toRightOf="#id/textDate"/>
<Spinner
android:id="#+id/spMonth"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_below="#+id/textNpersons"
android:layout_toRightOf="#id/spYear"/>
<Spinner
android:id="#+id/spDay"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_below="#+id/textNpersons"
android:layout_toRightOf="#id/spMonth"/>
<TextView
android:id="#+id/textTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_time"
android:layout_below="#+id/spDay"
android:textSize="7pt" />
<Spinner
android:id="#+id/spTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_toRightOf="#id/textTime"
android:layout_below="#+id/spDay"/>
<TextView
android:id="#+id/textComms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="10dip"
android:text="#string/form_comments"
android:layout_below="#+id/spTime"
android:textSize="7pt" />
<EditText
android:id="#+id/editComms"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:inputType="textMultiLine"
android:lines="2"
android:minLines="2"
android:gravity="top|left"
android:maxLines="5"
android:layout_below="#+id/spTime"
android:layout_toRightOf="#id/textComms"
android:scrollbars="vertical"/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editComms"
android:layout_centerHorizontal="true"
android:text="#string/form_snd_button" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
The ScrollView scrolls fine; however, the last button (#+id/button1) is not shown.
I've tried several combinations with match_parent and wrap_content for the contained layouts but with no luck.
Any ideas?
Thanks in advance.
Edit: Actually I'm writing my app so as to work in both tablets and phones. The above layout that belongs to a fragment works fine for phones.
In the case of tablets, the specific button is not shown. The above layout is attached to the Framelayout:aboutusdet shown in the code below:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/UnitId"/>
<FrameLayout
android:id="#+id/mainfrg"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_alignParentLeft="true"
/>
<FrameLayout
android:id="#+id/aboutusdet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/mainfrg"
android:layout_below="#+id/adView"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
/>
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/mainfrg" />
<TabWidget android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
Must be very simple to solve but I'm not able to solve this.
I want to align the "top image and log_in_box", so the whole thing appear in exact center (Horizontal+Vertical center) of the screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Current Look
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true" >
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription=""
android:src="#drawable/ic_launcher" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="User ID"
android:inputType="text" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password"
android:inputType="textPassword" />
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:checked="true"
android:text="Remember Me" />
<Button
android:id="#+id/log_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Log In" />