Android Emulator doesn't Scroll down - android

I am creating a layout as follows and when I emulate it in the AVD. It doesn't Scroll down to see the conten below the fold.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView android:text="#string/UserFormWelcome"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="20px" android:gravity="center" />
<TextView android:text="#string/name" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textStyle="bold"
android:paddingTop="20px" android:paddingLeft="10px" />
<TableLayout android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow android:layout_height="wrap_content"
android:layout_width="match_parent" android:paddingTop="20px">
<TextView android:text="#string/firstname"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:width="100px" android:paddingLeft="10px" />
<EditText android:id="#+id/LastName" android:width="200px"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView android:text="#string/lastname"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingLeft="10px" />
<EditText android:id="#+id/LastName" android:width="200px"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
<TextView android:text="#string/dob" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textStyle="bold"
android:paddingTop="20px" android:paddingLeft="10px" />
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:stretchColumns="3"
android:paddingTop="20px" android:paddingLeft="10px">
<TableRow>
<TextView android:text="#string/date" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="0" />
<TextView android:text="#string/month" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="1" />
<TextView android:text="#string/year" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="2" />
</TableRow>
<TableRow>
<Spinner android:id="#+id/spinnerDate" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="0" />
<Spinner android:id="#+id/spinnerMonth" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="1" />
<Spinner android:id="#+id/spinnerYear" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_column="2" />
</TableRow>
</TableLayout>
<LinearLayout android:id="#+id/linearLayout1"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:paddingLeft="10px">
<TextView android:text="#string/sex" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textStyle="bold"
android:paddingTop="20px" />
<RadioGroup android:id="#+id/radioGroup1"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton android:text="Male" android:id="#+id/rdbMale"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:paddingRight="20px" android:checked="true" />
<RadioButton android:text="Female" android:id="#+id/rdbFemale"
android:layout_height="wrap_content" android:layout_width="wrap_content" />
</RadioGroup>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingLeft="10px">
<TextView android:text="#string/city" android:id="#+id/textView3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:paddingTop="20px"
android:paddingBottom="10px" />
<Spinner android:id="#+id/citySpiner" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Spinner>
</LinearLayout>
</LinearLayout>

You should wrap your layout / the part you want to scoll into a ScrollView.
e.g. you can rewrite your layout as:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_height="wrap_content" android:layout_width="wrap_content">
<TextView [...]
[...]
</LinearLayout>
</ScrollView>
so your root tag will be a ScrollView, and you just paste your current layout inside.
you just need to remove the namespace declaration from your LinearLayout, and declare it in the ScrollView.
The ScrollView API Docs might be helpful, and of course, Romain Guy's "ScrollView's Handy tricks".

Related

Xamarin Android Button on Right an Left with Margin

I have a complex View, in that i need to set Buttons at the bottom of the page. I need two rows of bottons, with one on the left and two on the right.
The way I manage to solve this is like this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
...........
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center|bottom"
android:orientation="horizontal">
<TableLayout
android:stretchColumns="1"
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow
android:gravity="center_horizontal"
android:layout_height="wrap_content">
<Button
android:textSize="12sp"
android:id="#+id/btAnterior"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="A"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
<Button
android:layout_gravity="right"
android:textSize="12sp"
android:id="#+id/btnGuardar"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="G"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
<Button
android:layout_gravity="right"
android:textSize="12sp"
android:id="#+id/btnCancelar"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="C"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
</TableRow>
<TableRow
android:gravity="center_horizontal"
android:layout_height="wrap_content">
<Button
android:textSize="12sp"
android:id="#+id/btVolver"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="V"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
<Button
android:layout_gravity="right"
android:textSize="12sp"
android:id="#+id/btnMateriales"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="Materiales"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
<Button
android:layout_gravity="right"
android:textSize="12sp"
android:id="#+id/btnUltima"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:text="U"
android:background="#drawable/black_buttonSmall"
style="#style/button_text" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
It look like this
What I need is to set leftMargin on Left and Right.
How can I do it?
Actually why don't you try something like this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--Your code...-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
<Button
android:layout_width="wrap_content"
android:text="A"
android:layout_height="wrap_content"/>
<Button
android:layout_width="wrap_content"
android:text="B"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearContainerHelper"
android:layout_alignParentRight="true" >
<Button
android:layout_width="wrap_content"
android:text="C"
android:layout_height="wrap_content"/>
<Button
android:layout_width="wrap_content"
android:text="D"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/linearContainerHelper">
<Button
android:layout_width="wrap_content"
android:text="E"
android:layout_height="wrap_content"/>
<Button
android:layout_width="wrap_content"
android:text="F"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
If your parent-root is a RelativeLayout try using android:layout_alignParentBottom="true"istead of android:layout_gravity="bottom"

Android Horizontal Scroll View

i have a layout having many fields and i wish to add scrollbars for both horizontal and vertical layout.But vertical scroll is working horizontal scroll is not working.I have loaded the text fields dynamically in program and add the fields with web service .
My Activity
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutScroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
ImageView
Please keep in mind that the view that you want to scroll Horizontal is must have LinearLayout as parent then only you can set the HorizontalScrollView between that layout.
And Put one HorizontalScrollView as the Parent of those both LinearLayout.
Hope this will help you.
Smple:
<HORIZONTAL_VIEW ... >
<!-- Your First Layout -->
<LinearLayout ... >
</LinearLayout>
<!-- Your Second Layout -->
<LinearLayout ... >
</LinearLayout>
</HORIZONTAL_VIEW ... >
Hope you got my point.
Feel free for any query. :)
Try the Scroll Bars with out the Scrollview..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:scrollbars="horizontal|vertical"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>

TableLayout placing

How to place TableLayout a grid of buttons 5 on 5 on the screen center?
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/Table5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="30dp"
android:weightSum="5"/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:background="#ffffff"
android:gravity="center" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b11" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b12" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b13" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b14" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b15" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b21" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b22" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b23" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b24" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b25" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b31" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="b32" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b33" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b34" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b35" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b41" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b42" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b43" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b44" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b45" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b51" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b52" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b53" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b54" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b55" />
</TableRow>
</TableLayout>
</RelativeLayout>
Use the above code in an android layout XML file to create your 5x5 button matrix using a TableLayout
<GridView
android:id="#+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="#dimen/grid_width"
android:gravity="center"
android:numColumns="auto_fit"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:stretchMode="spacingWidth"
android:verticalSpacing="8dp" />
and into grid_width, you can set a dimension (for hdpi, 480/5).
I don't know if this work for your situation. But try it
Try adding android:layout_gravity="center" attribute to the TableLayout
(If that doesn't work, wrap the TableLayout with a LinearLayout or something like that.)

Android - Thin transparent line running through spinners, device specific?

Mysterious transparent lines are showing up in our spinners on certain devices. I've seen this before but there must be a way to get rid of them... I'm assuming it's something janky with the 9-patch used for the graphic.
Anyone have any advice? Layout snippet below:
<TableRow>
<Spinner
android:id="#+id/spinnerPostPage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_column="1" />
</TableRow>
UPDATE: Full layout below - no styling external to this layout is used:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg">
<RelativeLayout
android:id="#+id/layoutHeader"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:padding="10dp"
android:background="#008db9" >
<TextView
android:id="#+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/create_a_craze"
android:textSize="24dp" />
<Button
android:id="#+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginRight="5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="#string/save" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/layoutHeader" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="#+id/layoutBody"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/layoutHeader"
android:padding="5dp" >
<TableRow>
<TextView
android:id="#+id/textViewCrazeTitleLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#a1a0a3"
android:text="#string/craze_title_label" />
<EditText
android:id="#+id/editTextCrazeTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLength="50"
android:hint="#string/craze_title"/>
</TableRow>
<TableRow android:layout_width="fill_parent" android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonAddImage"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_gravity="center_vertical"
android:text="#string/add_image" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center" >
<ImageView
android:id="#+id/imageViewThumbnailOne"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:layout_margin="2dp"
android:visibility="gone" />
<ImageView
android:id="#+id/imageViewThumbnailTwo"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:layout_margin="2dp"
android:visibility="gone" />
<ImageView
android:id="#+id/imageViewThumbnailThree"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:layout_margin="2dp"
android:visibility="gone" />
</LinearLayout>
</TableRow>
<TableRow>
<CheckBox
android:id="#+id/checkBoxShareLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:textColor="#a1a0a3"
android:text="#string/share_location_map"
android:textSize="12dp" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textViewPostToLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="#a1a0a3"
android:text="#string/post_title_label" />
<Spinner
android:id="#+id/spinnerPostOptions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow>
<Spinner
android:id="#+id/spinnerPostPage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_column="1" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textViewShareCrazeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:textColor="#a1a0a3"
android:text="#string/share_craze_label" />
<Spinner
android:id="#+id/spinnerPrivacySettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_column="1" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textViewCrazeDescriptionLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#a1a0a3"
android:text="#string/craze_description_label" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/editTextCrazeDescription"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_below="#id/layoutBody"
android:minLines="3"
android:maxLines="5"
android:inputType="textMultiLine" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

How to scroll in android LinearLayout?

Hi i have an application, where i want to use scroll option in liner layout. Please help me i am stuck.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
>
<AnalogClock android:id="#+id/clock1" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:id="#+id/rssbtn" android:src="#drawable/rss"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<ProgressBar android:id="#+id/progress"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioGroup android:id="#+id/widget1" android:layout_width="wrap_content"
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<RadioButton android:id="#+id/widget2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Plain" android:checked="false" android:layout_gravity="left"
android:layout_weight="0">
</RadioButton>
<RadioButton android:id="#+id/widget3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Serif" android:checked="true" android:layout_gravity="left"
android:layout_weight="0" android:typeface="serif">
</RadioButton>
<RadioButton android:id="#+id/widget25"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Bold" android:checked="false" android:layout_weight="0"
android:layout_gravity="left" android:textStyle="bold">
</RadioButton>
</RadioGroup>
<Spinner android:id="#+id/widget1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:drawSelectorOnTop="false" />
<TimePicker android:id="#+id/widget3" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="#+id/plain_cb" android:text="Plain"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<CheckBox android:id="#+id/serif_cb" android:text="Serif"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="serif" />
<CheckBox android:id="#+id/bold_cb" android:text="Bold"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" />
<CheckBox android:id="#+id/italic_cb" android:text="Italic"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="italic" />
<Button android:id="#+id/button1" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent" />
<Button android:id="#+id/button2" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:typeface="serif" />
<Button android:id="#+id/button3" android:text="Label"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textStyle="italic" />
<DatePicker android:id="#+id/datepicker"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="#+id/edittext1" android:text="EditText 1"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="#+id/button2" android:text="(206)555-1212"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="serif" android:phoneNumber="true" />
<EditText android:id="#+id/password" android:text="SuperSecret"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textStyle="bold" android:password="true" />
</LinearLayout>
Wrap your LinearLayout in a ScrollView at the top of the file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="fill_parent">
<LinearLayout
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
>
.....
</LinearLayout>
</ScrollView>

Categories

Resources