I created a vertical linear layout and placed many items in it, and only part of them can be displayed on the screen. I can see the first several items of the layout but can't see the last several items of the layout.
How can I make the linear layout scrollable so the user can scroll the screen to see the last several items of the linear layout?
following is the content of the layout xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_gridw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Grid Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView_gridh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<TextView
android:id="#+id/textView_gridbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Border thickness"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridborderthickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_bgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="BgImg Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_bgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:inputType="number" />
<TextView
android:id="#+id/textView_bgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_bgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:inputType="number" />
<TextView
android:id="#+id/textView_mtgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="MTG Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_mtgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<TextView
android:id="#+id/textView_mtgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_mtgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Margin(left, top, right, bottom):"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText_margin_l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_r"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<TextView
android:id="#+id/textView_pathname_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Background image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_thumbdir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Thumbnail images directory path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_thumbdir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_treasure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Treasure image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_treasure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Signature image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="reset"
android:text="Reset" />
<Button
android:id="#+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="apply"
android:text="Apply" />
</LinearLayout>
</LinearLayout>
You should wrap your LinearLayout in a ScrollView:
Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.
You can use ScrollView, as follows:
<?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" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_gridw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Grid Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView_gridh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<TextView
android:id="#+id/textView_gridbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Border thickness"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_gridborderthickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_bgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="BgImg Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_bgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:inputType="number" />
<TextView
android:id="#+id/textView_bgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_bgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:inputType="number" />
<TextView
android:id="#+id/textView_mtgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="MTG Width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_mtgw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<TextView
android:id="#+id/textView_mtgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="Height"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_mtgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Margin(left, top, right, bottom):"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/editText_margin_l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_r"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/editText_margin_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number" />
</LinearLayout>
<TextView
android:id="#+id/textView_pathname_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Background image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_thumbdir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Thumbnail images directory path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_thumbdir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_treasure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Treasure image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_treasure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView_pathname_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Signature image file path name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText_pathname_signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="reset"
android:text="Reset" />
<Button
android:id="#+id/button_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="apply"
android:text="Apply" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Related
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.
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>
I have a ListView that I'm populating with an ArrayAdapter.Its work fine most of devices.But i have one karbonn(320x480) device which unable to display list.My application contain many listview they display properly on karbonn.
My .xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e6f0f5"
tools:context=".Save_educationActivity" >
<RelativeLayout
android:id="#+id/btnlayout"
android:layout_width="match_parent"
android:layout_height="47dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#4791FF"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/xibtn_save_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_save" />
<ImageButton
android:id="#+id/xibtn_back_to_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_back" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnlayout"
android:layout_marginTop="3dp"
android:text="#string/Education_title" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Course Name"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
<EditText
android:id="#+id/xedt_course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scrollView1"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/xedt_course"
android:text="Date"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView3"
android:text="Joining Date"
android:textSize="18dp" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/TextView01"
android:layout_alignBottom="#+id/TextView01"
android:layout_alignLeft="#+id/lvdate"
android:text="Leave Date"
android:textSize="18dp" />
<EditText
android:id="#+id/jdate"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/TextView01"
android:ems="10"
android:hint="Joining Date"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lvdate"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/TextView02"
android:ems="10"
android:hint="Leaving Date"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/jdate"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_education_desc"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:background="#drawable/date_stroke"
android:text="Add Description"
android:textColor="#ffffff"
android:textSize="20dp" />
<ImageButton
android:id="#+id/add_edu_desc"
android:layout_width="70dp"
android:layout_height="match_parent"
android:background="#drawable/date_stroke"
android:src="#drawable/ic_action_new"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/linearLayout1">
<ListView
android:id="#+id/lst_eductndesc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
</RelativeLayout>
You have very buggy layout. I will show you tour mistakes:
<RelativeLayout
android:id="#+id/btnlayout"
android:layout_width="match_parent"
android:layout_height="47dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#4791FF"
android:orientation="horizontal" > // there is no such attribute in relative layout
<ImageButton
android:id="#+id/xibtn_save_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_save" />
<ImageButton
android:id="#+id/xibtn_back_to_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_back" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnlayout"
android:layout_marginTop="3dp"
android:text="#string/Education_title" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" // which size of scroll view you expected here? It will grow with their content and never have scroll.
android:layout_below="#+id/textView1" >
<RelativeLayout // you don't need to have relative layout here.
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Course Name"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
<EditText
android:id="#+id/xedt_course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scrollView1"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/xedt_course"
android:text="Date"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView3"
android:text="Joining Date"
android:textSize="18dp" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/TextView01"
android:layout_alignBottom="#+id/TextView01"
android:layout_alignLeft="#+id/lvdate"
android:text="Leave Date"
android:textSize="18dp" />
<EditText
android:id="#+id/jdate"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/TextView01"
android:ems="10"
android:hint="Joining Date"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lvdate"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/TextView02"
android:ems="10"
android:hint="Leaving Date"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/jdate"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_education_desc"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:background="#drawable/date_stroke"
android:text="Add Description"
android:textColor="#ffffff"
android:textSize="20dp" />
<ImageButton
android:id="#+id/add_edu_desc"
android:layout_width="70dp"
android:layout_height="match_parent"
android:background="#drawable/date_stroke"
android:src="#drawable/ic_action_new"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" // which height you expect here? It will have height the same as parent, but draws somewhere at the bottom. It will draw a large part of view outside of screen.
android:layout_below="#+id/linearLayout1">
<ListView
android:id="#+id/lst_eductndesc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
I think you need reformat your layout at all. If you will show image what you want to achieve and explain it's behavior, I will help to write more effeicient and clean xml.
You can make your layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e6f0f5"
tools:context=".Save_educationActivity"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/btnlayout"
android:layout_width="match_parent"
android:layout_height="47dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#4791FF"
android:orientation="horizontal" > // there is no such attribute in relative layout
<ImageButton
android:id="#+id/xibtn_save_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_save" />
<ImageButton
android:id="#+id/xibtn_back_to_education"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:background="#4791FF"
android:src="#drawable/ic_action_back" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="#string/Education_title" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="50dp" // you must declare your height exactly here
>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Course Name"
android:textSize="18dp"
android:textStyle="bold" />
</ScrollView>
<EditText
android:id="#+id/xedt_course"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scrollView1"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/xedt_course"
android:text="Date"
android:textSize="18dp"
android:textStyle="bold" />
<LinearLayout layout_width="match_parent"
layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout layout_width="0dp"
laout_weight="1"
layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView3"
android:text="Joining Date"
android:textSize="18dp" />
<EditText
android:id="#+id/jdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Joining Date"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout layout_width="0dp"
laout_weight="1"
layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Leave Date"
android:textSize="18dp" />
<EditText
android:id="#+id/lvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Leaving Date"
android:inputType="textPersonName" >
</EditText>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_education_desc"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:background="#drawable/date_stroke"
android:text="Add Description"
android:textColor="#ffffff"
android:textSize="20dp" />
<ImageButton
android:id="#+id/add_edu_desc"
android:layout_width="70dp"
android:layout_height="match_parent"
android:background="#drawable/date_stroke"
android:src="#drawable/ic_action_new"
android:visibility="gone" />
</LinearLayout>
<ListView
android:id="#+id/lst_eductndesc"
android:layout_width="match_parent"
android:layout_height="0dp"
layout_weight="1"
android:layout_centerHorizontal="true" >
</LinearLayout>
Since you're using RelativeLayouts and aligning your views beneath one another, it's likely that the layout is extending beyond the bottom of the screen.
I encourage you to use a different combination of ViewGroups, for instance using a vertically oriented LinearLayout inside a ScrollView.
The next code is OK for Eclipse Layout Editor and Android Studio. I tested it in several mobiles and works fine but, in a Samsung GT-S6310N (Android 4.1.2), this EditText dissapears. It goes at the end of a LinearLayout that defines the Layout width. The Layout is showed in a Dialog using android:Theme.Dialog.
<EditText
android:id="#+id/et_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
I've solved this changing the code to:
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
The question is: is wrong mi code or is a bug?
This is the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
tools:context=".Measure" >
<RelativeLayout
android:id="#+id/rl_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignBaseline="#+id/et_from"
android:text="#string/from"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/TextView1"
android:ems="7"
android:hint="#string/from"
android:lines="1"
android:maxLength="7"
android:minLines="1"
android:nextFocusDown="#+id/et_to"
android:text="1234567" />
<EditText
android:id="#+id/et_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentRight="true"
android:ems="7"
android:hint="#string/to"
android:maxLength="7"
android:maxLines="1"
android:nextFocusDown="#+id/et_distance"
android:text="1234567" />
<TextView
android:id="#+id/TextView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_toLeftOf="#+id/et_to"
android:text="#string/to"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/green" />
<EditText
android:id="#+id/et_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:hint="#string/distance_abr"
android:inputType="numberDecimal"
android:lines="5"
android:maxLength="6"
android:nextFocusDown="#+id/et_rumbomag" />
<TextView
android:id="#+id/TextView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rumbo_mn_abr"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_rumbomag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:hint="#string/rumbo_mn_abr"
android:inputType="numberDecimal"
android:maxLength="5"
android:nextFocusDown="#+id/et_measured_clino"
android:text="360.0" />
<TextView
android:id="#+id/tv_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clino"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
<!-- Así produce error: el et_clino desaparece y el tv_clino se estrecha y muestra el texto en 3 líneas
<EditText
android:id="#+id/et_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
-->
</LinearLayout>
<LinearLayout
android:id="#+id/ll_d"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/rg_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rb_direct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:hint="#string/direction"
android:text="#string/direct" />
<RadioButton
android:id="#+id/rb_inverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="#string/inverse" />
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<!--
<Button
android:id="#+id/btn_get_from_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BT"
android:textColor="#color/blue" />
-->
<Button
android:id="#+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/delete"
android:textColor="#color/red" />
<ImageButton
android:id="#+id/ib_disto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/disto" />
<Button
android:id="#+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/save"
android:textColor="#color/green" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_e"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/description" >
<requestFocus />
</EditText>
</LinearLayout>
I've made some changes (particularly the LinearLayout containing the cli_no EditText, #string and #drawable resources) in the xml file as below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/rl_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentLeft="true"
android:text="#string/from"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/TextView1"
android:ems="7"
android:hint="#string/from"
android:lines="1"
android:maxLength="7"
android:minLines="1"
android:nextFocusDown="#+id/et_to"
android:text="1234567" />
<EditText
android:id="#+id/et_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentRight="true"
android:ems="7"
android:hint="#string/to"
android:maxLength="7"
android:maxLines="1"
android:nextFocusDown="#+id/et_distance"
android:text="1234567" />
<TextView
android:id="#+id/TextView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_toLeftOf="#+id/et_to"
android:text="#string/to"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv_distance"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/green" />
<EditText
android:id="#+id/et_distance"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="4"
android:layout_weight="1"
android:hint="distance_abr"
android:inputType="numberDecimal"
android:lines="5"
android:maxLength="6"
android:nextFocusDown="#+id/et_rumbomag" />
<TextView
android:id="#+id/TextView3"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_rumbomag"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ems="4"
android:hint="rumbo"
android:inputType="numberDecimal"
android:maxLength="5"
android:text="360.0" />
<TextView
android:id="#+id/tv_clino"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="clino"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_d"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/rg_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rb_direct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:hint="direction"
android:text="direct" />
<RadioButton
android:id="#+id/rb_inverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="inverse" />
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<!--
<Button
android:id="#+id/btn_get_from_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BT"
android:textColor="#color/blue" />
-->
<Button
android:id="#+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/delete" />
<ImageButton
android:id="#+id/ib_disto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/back02" />
<Button
android:id="#+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="save"
android:textColor="#color/green" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_e"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/description" >
<requestFocus />
</EditText>
</LinearLayout>
The reason for disappearing of the EditText is that you want to display items, which has total width greater than the width of the screen, so I've applied same layout_weight:"1" to all the elements inside the LinearLayout. May be this helps you for solving your issue.
<?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"
>
<ScrollView
android:id="#+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:id="#+id/MainParent"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="454dp"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80sp"
android:text="Sim Card Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/simno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:text="Sim No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/simName"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:selectAllOnFocus="true" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/TextView01"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:text="Service Provider"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/service_arrays"
android:prompt="#string/serviceprovid" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100sp"
android:layout_marginTop="5dp"
android:text="Unit Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:text="Unit No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/unitNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true" />
<TextView
android:id="#+id/TextView04"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:text="IMEI No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/imeiNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true"/>
<TextView
android:id="#+id/vehicleNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80sp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="Vehicle Master"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/pumpkinorange"
android:textSize="17sp" />
<TextView
android:id="#+id/TextView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Vehicle No"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/darkblue"
android:textSize="14sp" />
<EditText
android:id="#+id/vehicleNo"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:selectAllOnFocus="true"/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_gravity="center"
android:text="Save"
android:textSize="15sp"
android:textStyle="italic"
android:typeface="normal" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="Reset"
android:textSize="15sp"
android:textStyle="italic"
android:typeface="normal" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I don't know to correct this error. In xml layout i can see the button, but in the emulator its not visible or button not scrolled. also i want this two button in same line with left and right alignment.
You Specified inside scrollview second linearlayout as
<LinearLayout
android:layout_width="match_parent"
android:layout_height="454dp"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
change to
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:orientation="vertical" >
You Specified height fixed that why it does't display...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="3dp"
>
<Button
android:id="#+id/login_btn"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.5"
android:text="Login"
/>
<Button
android:id="#+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="0.5"
android:text="Cancel"
/>
</LinearLayout>
Set your ScrollView's height to match_parent
<ScrollView
android:id="#+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >