ScrollView展示滚动图片

1. 滚动视图效果:

 2. 代码实现:

(1)AVD模拟器内存配置:

      根据图片资源的大小,调整合适的内存空间,本程序的参数调整如下:

 (2)工程目录结构:

(3)MainActivity.java代码:

package com.example.scrollview;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
}

(4)activity_main.xml 布局代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="垂直滚动视图"
            android:textSize="30dp" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p1" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p2" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p3" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p4" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p5" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p6" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p7" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p8" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p9" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="580dp"
            android:src="@drawable/p10" />
    </LinearLayout>

</ScrollView>

(5)把图片放在drawable目录下:

至此结束。

3. 源代码位置:https://github.com/diaoguangqiang/android/blob/Image/ScrollView.rar

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值