Android学习笔记技巧之垂直和水平滚动视图-LMLPHPAndroid学习笔记技巧之垂直和水平滚动视图-LMLPHP

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content" >
  5. <HorizontalScrollView
  6. android:layout_width="fill_parent"
  7. android:layout_height="wrap_content" >
  8. <RelativeLayout
  9. android:layout_width="fill_parent"
  10. android:layout_height="fill_parent"
  11. android:orientation="horizontal" >
  12. <TextView
  13. android:id="@+id/textview1"
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:gravity="center_vertical"
  17. android:text="垂直和水平滚动"
  18. android:textSize="30dp" />
  19. <ImageView
  20. android:id="@+id/imageview1"
  21. android:layout_width="wrap_content"
  22. android:layout_height="wrap_content"
  23. android:layout_below="@id/textview1"
  24. android:src="@drawable/item1" />
  25. <ImageView
  26. android:id="@+id/imageview2"
  27. android:layout_width="wrap_content"
  28. android:layout_height="wrap_content"
  29. android:layout_toRightOf="@id/imageview1"
  30. android:layout_below="@id/textview1"
  31. android:src="@drawable/item2" />
  32. <TextView
  33. android:id="@+id/textview2"
  34. android:layout_width="wrap_content"
  35. android:layout_height="wrap_content"
  36. android:layout_below="@id/imageview1"
  37. android:text="垂直和水平滚动"
  38. android:textSize="30dp" />
  39. <ImageView
  40. android:id="@+id/imageview2"
  41. android:layout_width="wrap_content"
  42. android:layout_height="wrap_content"
  43. android:layout_below="@id/textview2"
  44. android:src="@drawable/item3" />
  45. </RelativeLayout>
  46. </HorizontalScrollView>
  47. </ScrollView>
    1. package net.blogjava.mobile;
    2. import android.app.Activity;
    3. import android.os.Bundle;
    4. public class Main extends Activity {
    5. /** Called when the activity is first created. */
    6. @Override
    7. public void onCreate(Bundle savedInstanceState) {
    8. super.onCreate(savedInstanceState);
    9. setContentView(R.layout.main);
    10. }
    11. }
05-07 11:47