1. 程式人生 > >Android 開發筆記___滾動視圖__scroll view

Android 開發筆記___滾動視圖__scroll view

protected apk sch view col extend linear scroll set

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:orientation="vertical" android:layout_width="match_parent"
 4     android:layout_height="match_parent">
 5 
 6     <TextView
 7         android:layout_width="wrap_content"
8 android:layout_height="wrap_content" 9 android:text="演示效果" 10 android:textColor="@color/text_color" 11 android:textSize="25sp" 12 android:layout_gravity="center"/> 13 14 <LinearLayout 15 android:layout_width="match_parent" 16 android:layout_height
="200dp"> 17 18 <HorizontalScrollView 19 android:layout_width="wrap_content" 20 android:layout_height="match_parent"> 21 22 <LinearLayout 23 android:layout_width="wrap_content" 24 android:layout_height="match_parent"
> 25 26 <View 27 android:layout_width="400dp" 28 android:background="#aaffff" 29 android:layout_height="match_parent"/> 30 31 <View 32 android:layout_width="400dp" 33 android:layout_height="match_parent" 34 android:background="#ffff00"/> 35 36 </LinearLayout> 37 </HorizontalScrollView> 38 39 </LinearLayout> 40 41 <ScrollView 42 android:fillViewport="true" 43 android:layout_width="match_parent" 44 android:layout_height="wrap_content"> 45 46 <LinearLayout 47 android:layout_width="match_parent" 48 android:orientation="vertical" 49 android:layout_height="wrap_content"> 50 51 <View 52 android:layout_width="match_parent" 53 android:background="#aa5511" 54 android:layout_height="400dp"/> 55 56 <View 57 android:layout_width="match_parent" 58 android:layout_height="400dp" 59 android:background="#ffff00"/> 60 61 <TextView 62 android:layout_width="match_parent" 63 android:layout_height="wrap_content" 64 android:text="scrollview 的使用,有兩種。\n垂直方向、水平方向。\n視圖裏面只能放一個布局"/> 65 66 </LinearLayout> 67 68 </ScrollView> 69 70 </LinearLayout>

java

 1 package com.example.alimjan.hello_world;
 2 
 3 import android.app.Activity;
 4 import android.content.Context;
 5 import android.content.Intent;
 6 import android.os.Bundle;
 7 import android.support.annotation.Nullable;
 8 
 9 /**
10  * Created by alimjan on 6/30/2017.
11  */
12 
13 public class class__2_2_3 extends Activity {
14     @Override
15     protected void onCreate(@Nullable Bundle savedInstanceState) {
16         super.onCreate(savedInstanceState);
17         setContentView(R.layout.code_2_2_3);
18     }
19 
20     public static void startHome(Context mContext) {
21         Intent intent = new Intent(mContext, class__2_2_3.class);
22         mContext.startActivity(intent);
23     }
24 }

Android 開發筆記___滾動視圖__scroll view