Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to scroll screen in android

Tags:

android

scroll

I'm learning the android. I created a simple xml screen but data is going out of screen and the screen is not scrolling. Can any body tell me how to make scrollable my phone screen?

like image 539
ashfak Avatar asked Feb 25 '23 07:02

ashfak


2 Answers

Put it inside a ScrollView

http://developer.android.com/reference/android/widget/ScrollView.html

like image 146
Aleadam Avatar answered Feb 26 '23 21:02

Aleadam


Here is some code for a fixed header and fixed footer and a scrolling body:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="fill_parent"
  android:id="@+id/relativeLayout1"
  android:layout_width="wrap_content">
<TextView
  android:text="Header"
  android:id="@+id/textViewHeader"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
<TextView
  android:layout_alignParentBottom="true"
  android:text="Footer"
  android:id="@+id/textViewFooter"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
<ScrollView
  android:layout_above="@id/textViewFooter"
  android:layout_below="@id/textViewHeader"
  android:layout_height="fill_parent"
  android:layout_width="fill_parent"
  >
<LinearLayout
  android:layout_below="@id/textViewHeader"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
<TextView android:text="@string/about_tlh_body"
  android:id="@+id/textViewBody"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</ScrollView>
</RelativeLayout>

Have fun.

like image 33
JAL Avatar answered Feb 26 '23 19:02

JAL