时间控件,显示时分,中间”:”跳动
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.loonggg:TextViewClock:1.1'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.loonggg</groupId>
<artifactId>TextViewClock</artifactId>
<version>1.1</version>
</dependency>
- clockTextSize 设置时间字体大小
- clockTextColor 设置时间字体颜色
- space 设置时间,时,分和冒号之间间距大小
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.loonggg.textviewclock.MainActivity">
<com.loonggg.textviewclock.lib.TextViewClock
android:id="@+id/tvc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:clockTextSize="30sp"
app:space="18dp" />
</RelativeLayout>
public class MainActivity extends AppCompatActivity {
private TextViewClock tvc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvc = (TextViewClock) findViewById(R.id.tvc);
Typeface typeface = Typeface.createFromAsset(this.getAssets(), "fonts/weds.ttf");
tvc.setFontTypeface(typeface);
}
}
欢迎大家关注我的微信公众号:非著名程序员(smart_android),更多好的原创文章均首发于微信订阅号:非著名程序员
Copyright 2017 loonggg
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.