Code Monkey home page Code Monkey logo

luckyboard's Introduction

LuckyBoard

仿王者荣耀低配夺宝控件

效果图

特性

1、可根据添加奖品数自适应精品规模,无需规定多少奖品。
2、支持网络奖品图片加载。
3、可设置奖品区域背景,控件背景。

使用方法

1.添加控件到layout布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.luozm.luckyboarddemo.MainActivity">

   <com.luozm.luckyboard.LuckyBoard
       android:id="@+id/luckyboard"
       android:layout_gravity="center"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"/>

</LinearLayout>

2.Java代码初始化

public class MainActivity extends AppCompatActivity {

    LuckyBoard luckyBoard;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        luckyBoard = (LuckyBoard) findViewById(R.id.luckyboard);
         List<LuckyAward> awards = new ArrayList<>();
        awards.add(new LuckyAward("阿珂", "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=249354644,175269563&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("百里守约", "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2259891641,813905710&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("曹操", "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2639560139,842609066&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("黄忠", "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=579192554,2336386543&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("刘备", "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1620262605,627001861&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("夏侯惇", "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2623316471,2443593485&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("张飞", "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2445078472,4134287578&fm=27&gp=0.jpg", 0.1f));
        awards.add(new LuckyAward("赵云", "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=16058097,1380439742&fm=27&gp=0.jpg", 0.1f));
        luckyBoard.setAvAward(new LuckyAward("谢谢惠顾", "http://img3.imgtn.bdimg.com/it/u=2627630245,3498178596&fm=27&gp=0.jpg", 0f));
        luckyBoard.setAwards(awards);
        luckyBoard.setResultCallback(new LuckyBoard.ResultCallback() {
            @Override
            public void result(LuckyAward award) {
                Toast.makeText(MainActivity.this, award.getName(), Toast.LENGTH_SHORT).show();
            }
        });
    }


}

博客文章

SurfaceView实战打造农药钻石夺宝

luckyboard's People

Contributors

luozhanming avatar

Watchers

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