<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="演示效果"
android:textColor="@color/text_color"
android:textSize="25sp"
android:layout_gravity="center"/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"> <HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"> <View
android:layout_width="400dp"
android:background="#aaffff"
android:layout_height="match_parent"/> <View
android:layout_width="400dp"
android:layout_height="match_parent"
android:background="#ffff00"/> </LinearLayout>
</HorizontalScrollView> </LinearLayout> <ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"> <View
android:layout_width="match_parent"
android:background="#aa5511"
android:layout_height="400dp"/> <View
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#ffff00"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="scrollview 的使用,有两种。\n垂直方向、水平方向。\n视图里面只能放一个布局"/> </LinearLayout> </ScrollView> </LinearLayout>
java
package com.example.alimjan.hello_world; import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable; /**
* Created by alimjan on 6/30/2017.
*/ public class class__2_2_3 extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.code_2_2_3);
} public static void startHome(Context mContext) {
Intent intent = new Intent(mContext, class__2_2_3.class);
mContext.startActivity(intent);
}
}