android 特效闹钟GoogleClock

项目地址: GoogleClock
简介:The core of it is SVG .

An imitation of the clock in Google I/O 2016 . Almost all of the animations and images in it are made by the SVG , so this library may be a wonderful material to learn the SVG's usage in Android . Chinese README is here .

show

GoogleClock

Installation

You can install GoogleClock by adding the following dependency to your build.gradle:

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
}
dependencies {
            compile 'com.github.lypeer:GoogleClock:1.0.0'
}

Usage

Simple Usage :

Just to add the GoogleClock to your activity's xml :

<com.lypeer.googleioclock.GoogleClock
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

And then the clock will appear .

Complex Usage

Of course , you can do some configuration in the xml :

<com.lypeer.googleioclock.GoogleClock
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:lyClockWidth="32dp"
        app:lyHourWidth="32dp"
        app:lyMinWidth="32dp"
        app:lySecWidth="32dp"
        app:lyDividerHorizontal="32dp"
        app:lyDividerVertical="32dp"
        app:lyTheme="@style/LyTheme3"
        />

You can configure the following xml attributes for the clock :

attributevalue typedefalut valuedescription
lyClockWidthdimen0dpThe size of numbers in the clock . But it's priority is lower than the below three attributes .
lyHourWidthdimen48dpThe size of the hour part in the clock .
lyMinWidthdimen48dpThe size of the minutes part in the clock .
lySecWidthdimen32dpThe size of the second part in the clock .
lyDividerHorizontaldimen4dpThe divider's width between the two number in hour , minute and snecond .
lyDividerVerticaldimen16dpThe devider's width of the two lines (Hours and mintues are in the same line while seconds the other).
lyThemereferenceLyThemeThe custom theme .

Your can define a custom theme to change more in the clock , such as following :

<style name="LyTheme2" parent="LyTheme">
        <item name="lyColor0">@color/colorRed</item>
        <item name="lyColor1">@color/colorYellow</item>
        <item name="lyColor2">@color/colorGreen</item>
        <item name="lyColor3">@color/colorBlue</item>
        <item name="lyColorColon">@color/colorDarkBlue</item>
        <item name="lyThickness">@integer/lyThickness_4</item>
        <item name="lyColonThickness">@integer/lyThickness_1</item>
</style>

You should let The custom theme's parent be LyTheme so that you can only override the attributes you want to change . If not , your theme must contains all of the attributes in LyTheme , or some view may can't work . LyTheme contains following attributes :

attributesvalue typedefault valuedescription
lyColor0color@color/colorRedThe first color in the numbers .
lyColor1color@color/colorYellowThe second color in the numbers .
lyColor2color@color/colorGreenThe third color in the numbers .
lyColor3color@color/colorBlueThe forth color in the numbers .
lyColorColoncolor@color/colorDarkBlueThe color of the colon .
lyThicknessinteger4Number's thickness .
lyColonThicknessinteger1Colon's thickness .

Ok , that's all about usage . There is a demo in the library .

Dependencies

  • org.greenrobot:eventbus:3.0.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值