Android開源:AdCountView - 漂亮的自定義計時組件

ycif6120 7年前發布 | 5K 次閱讀 安卓開發 Android開發 移動開發

AdCountView

an simple CountView for advertisement

Step 1

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2

Add the dependency

dependencies {
         compile 'com.github.flyou:AdCountView:1.0.3'
}

Step 3

Input in your xml

<com.flyou.AdCountView
        android:id="@+id/ad_count_view1"
        android:layout_width="80dp"
        android:layout_height="80dp"

    /></code></pre> 

Or some attribute

<com.flyou.AdCountView

    android:id="@+id/ad_count_view1"
    app:text="enter app"
    app:textColor="@color/base_white_50"
    app:textSize="16dp"
    app:backgroundColor="@color/base_black_50"
    app:outRingColor="@color/colorAccent"
    android:layout_width="80dp"
    android:layout_height="80dp"

    /></code></pre> 

Step 4

adCountView1 = (AdCountView) findViewById(R.id.ad_count_view1);
    adCountView1.start();

Or more configure

adcountview1 = (AdCountView) findViewById(R.id.ad_count_view2);
    adcountview1.setbackgroundColor(getResources().getColor(R.color.base_white_80));
    adcountview1.setOutRingColor(getResources().getColor(R.color.colorAccent));
    adcountview1.setTextClor(getResources().getColor(R.color.base_black_100));
    adcountview1.setText("進入應用");
    adcountview1.start();

Or

adcountview3 = (AdCountView) findViewById(R.id.ad_count_view3);
    adcountview3.setbackgroundColor(getResources().getColor(R.color.base_black_30));
    adcountview3.setOnClickListener(this);
    adcountview3.setOnStatusChangeListener(this);
    adcountview3.setOutRingColor(getResources().getColor(R.color.lightseagreen));
    adcountview3.setTextClor(getResources().getColor(R.color.base_white_100));
    adcountview3.setText("跳過廣告");
    adcountview3.setTextSize(15);
    adcountview3.start();

Instructions

  • setText() set text of view show
  • setTextColor() set text color
  • setTextSize() set text size
  • setTime() set animation time
  • setBackgroundColor() set circle background color
  • setOutRingColor() set out ring color
  • setOnStatusChangeListener() anim start or stop listener

 

 

 本文由用戶 ycif6120 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!