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

 

  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.   
  6.     <HorizontalScrollView  
  7.         android:layout_width="fill_parent"  
  8.         android:layout_height="wrap_content" >  
  9.   
  10.         <RelativeLayout  
  11.             android:layout_width="fill_parent"  
  12.             android:layout_height="fill_parent"  
  13.             android:orientation="horizontal" >  
  14.   
  15.             <TextView  
  16.                 android:id="@+id/textview1"  
  17.                 android:layout_width="wrap_content"  
  18.                 android:layout_height="wrap_content"  
  19.                 android:gravity="center_vertical"  
  20.                 android:text="垂直和水平滚动"  
  21.                 android:textSize="30dp" />  
  22.               
  23.             <ImageView  
  24.                 android:id="@+id/imageview1"  
  25.                 android:layout_width="wrap_content"  
  26.                 android:layout_height="wrap_content"  
  27.                 android:layout_below="@id/textview1"  
  28.                 android:src="@drawable/item1" />  
  29.   
  30.             <ImageView  
  31.                 android:id="@+id/imageview2"  
  32.                 android:layout_width="wrap_content"  
  33.                 android:layout_height="wrap_content"  
  34.                 android:layout_toRightOf="@id/imageview1"  
  35.                 android:layout_below="@id/textview1"  
  36.                 android:src="@drawable/item2" />  
  37.   
  38.             <TextView  
  39.                 android:id="@+id/textview2"  
  40.                 android:layout_width="wrap_content"  
  41.                 android:layout_height="wrap_content"  
  42.                 android:layout_below="@id/imageview1"  
  43.                 android:text="垂直和水平滚动"  
  44.                 android:textSize="30dp" />  
  45.   
  46.             <ImageView  
  47.                 android:id="@+id/imageview2"  
  48.                 android:layout_width="wrap_content"  
  49.                 android:layout_height="wrap_content"  
  50.                 android:layout_below="@id/textview2"  
  51.                 android:src="@drawable/item3" />  
  52.         </RelativeLayout>  
  53.     </HorizontalScrollView>  
  54.   
  55. </ScrollView>  


 

    1. package net.blogjava.mobile;  
    2.   
    3. import android.app.Activity;  
    4. import android.os.Bundle;  
    5.   
    6. public class Main extends Activity {  
    7.     /** Called when the activity is first created. */  
    8.     @Override  
    9.     public void onCreate(Bundle savedInstanceState) {  
    10.         super.onCreate(savedInstanceState);  
    11.         setContentView(R.layout.main);  
    12.     }  
posted @ 2017-04-17 11:45  brave-sailor  阅读(249)  评论(0编辑  收藏  举报