android判題自定義view

RightOrWrongView


這是一個判斷對錯的動畫,場景可以用於試題的應用,來判斷做題的正誤啦:)

正確演示

錯誤演示

引入到你的項目


1.copy BallView.java 和 mipmap-xxhdpi裏面的圖片到項目中即可
2. 在values中的attrs.xml中添加

    <declare-styleable name="circle">
        <attr name="circleWidth" format="dimension"></attr>
        <attr name="circleHeight" format="dimension"></attr>
        <attr name="circleColor" format="color"/>
    </declare-styleable>

用法


1.在xml中調用

    <com.app.myapplication.RightOrWrongView
        android:id="@+id/rwview"
        android:layout_width="200dp"
        android:layout_height="200dp"
        hj:circleWidth = "200dp"
        hj:circleHeight = "200dp"
        android:visibility="gone"/>

2.在Activity中調用

        rwview = (RightOrWrongView) findViewById(R.id.rwview);
        tv = (TextView) findViewById(R.id.tv);
        rwview.setRightOrWrong(RightOrWrongView.RIGHT);

注意,可能你會要在動畫結束後進行一些操作,那麼請加上監聽

        rwview.setCircleListener(new RightOrWrongView.CircleListener() {
            @Override
            public void AnimFinish() {
                tv.setText("動畫執行完畢");
            }
        });

下載


github下載地址:https://github.com/AnthonyEver/RightOrWrongView
喜歡請點個star~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章