开发者

how to scroll screen in android

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


Put it inside a ScrollView

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


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.


Make your Activity a ListActivity

Here is an example that implements a listView / ListActivity

http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/

Scroll to the bottom of the post to find the Eclipse project to see the full implementation.

You can also use a http://developer.android.com/reference/android/widget/ScrollView.html


Puth the whole layout inside scrollView.i.e the topmost/parent layout is scrollview


Just put this code in your activity of AndroidManifest.xml

android:windowSoftInputMode="stateVisible|adjustResize"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜