Coder Social home page Coder Social logo

hotimg's Introduction

HotImg

图片不规则区域点击事件处理

HotImg是基于对一张图片进行不规则区域点击响应不同事件。

基本内容

1.对图片的部分区域进行可响应事件
2.对图片进行缩放后,仍可响应区域点击事件
3.对图片进行移动后.仍可响应区域点击事件
4.当图片移出边界区域后,可进行回弹.

如何使用

1、 xml配置

    <com.dreamlive.hotimglibrary.view.HotClickView
        android:id="@+id/a_main_hotview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

2、 禁止缩放

       mHotView.setCanScale(false);

3、 禁止滑动

       mHotView.setCanMove(false);

4、 设置监听事件

        mHotView.setOnClickListener(new HotClickView.OnClickListener() {
            @Override
            public void OnClick(View view, HotArea hotArea) {
                Toast.makeText(MainActivity.this, "你点击了" + hotArea.getDesc(), Toast.LENGTH_SHORT).show();
            }
        });

5、 图片点击区域的设置
将图片中每个点击区域的像素坐标点配置assets文件下的xml中,例如一张图片像素800X600,在其坐上方(从左上方顶点开始)有一个50x50的正方形点击区域,那么他们pts为{0,0,0,50,50,50,50,0}也就是正方形的四个区域。

Thanks

Everyone who has contributed code and reported issues and pull requests!

hotimg's People

Contributors

dreamlivemeng avatar name-mengwei avatar

Watchers

James Cloos avatar coder 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.