Android中Gallery常用功能3----幻灯片效果,手势滑动大图切换

本文介绍了如何在Android中使用Gallery组件实现手势滑动切换大图的效果,提供了项目结构和源码下载链接,可以作为ViewPager实现类似功能的一个参考。
摘要由CSDN通过智能技术生成

效果图:

项目结构:

 在 https://blog.csdn.net/zhaihaohao1/article/details/100049893

的基础上,加入滑动大图切换画廊

ViewPager也能实现类似效果,所以放到ViewPager的分类中

代码如下:

activity_image_switcher.xml 中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <ImageSwitcher
        android:id="@+id/imageSwitcher"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:scaleType="fitXY"
        android:layout_gravity="center_horizontal"
        />
    <!--spacing子控件之间的间距-->
    <!--unselectedAlpha未选中子控件的透明度-->
    <Gallery
        android:id="@+id/gallery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:spacing="10dp"
        android:unselectedAlpha="0.5"
        android:layout_marginTop="10dp"
        />

</LinearLayout>
ImageSwitcherActivity 中
package com.example.app2;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchLi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值