Giter Club home page Giter Club logo

gallery's Introduction

Gallery

viewpager实现的Gallery库
项目分为app(demo工程),mylib(依赖库工程)
Gallery的item可以自定义布局

Gallery库的使用

直接使用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:gallery="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    android:background="@android:color/darker_gray">

    <com.example.like.mylibrary.Gallery
        android:id="@+id/gallery"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.example.like.mylibrary.Gallery>


</LinearLayout>
定义Gallery

定义Gallery主图片两侧的边距 gallery_padding(也可使用 gallery_padding_top等等)
定义Gallery图片间的间距 gallery_pics_space
定义Gallery图片缩小的最小比例 scaleP
例如:

    <com.example.like.mylibrary.Gallery
        android:id="@+id/gallery"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        gallery:scaleP="0.9"
        gallery:gallery_pics_space="20dp"
        gallery:gallery_padding="50dp">
    </com.example.like.mylibrary.Gallery>

为Gallery设置数据

参考了base-adapter-helper的实现方式,可以方便的为Gallery设置布局与数据

mQuickPagerAdapter = new QuickPagerAdapter<Bean>(this, R.layout.gallery_item_layout, data) {
            @Override
            protected void convertView(BaseAdapterHelper helper, final Bean item) {
                helper.setImageResource(R.id.imageview, item.getImgResId());
                helper.setText(R.id.textview, getString(item.getStrResId()));
                helper.setImageOnClickListener(R.id.imageview, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(getBaseContext(), getString(item.getStrResId()), Toast.LENGTH_SHORT).show();
                    }
                });
            }
        };
        gallery.setAdapter(mQuickPagerAdapter);

效果图

image

参考内容

Gallery滑动一页(一个Item)效果
base-adapter-helper 项目,但是已经找不到原来的地址,知道的可以给我说下

gallery's People

Contributors

achenglike avatar bryant1410 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.