The ViewUtils is a library for android which helps you to custom a some views more easily.
##Download ViewUtils to your project Add the following code to your module's build.gradle file:
dependencies {
compile 'com.github.jeffersonrojas:viewutils:1.0.6'
}
Add Vector Compound Drawables since api 10, and specify the tint color.
- first configure your project for use the library support vectors, if you do not know how to configure you can follow this tutorial
- set your vector compound drawables
<com.github.jeffersonrojas.viewutils.library.EditText
app:tintCompound="@color/colorAccent"
app:drawableStart="@drawable/ic_your_vector"
app:drawableTop="@drawable/ic_your_vector"
app:drawableEnd="@drawable/ic_your_vector"
app:drawableBottom="@drawable/ic_your_vector"
... />
<com.github.jeffersonrojas.viewutils.library.EditText
app:tintDrawableStart="@color/blue"
app:drawableStart="@drawable/ic_your_vector"
app:tintDrawableTop="@color/red"
app:drawableTop="@drawable/ic_your_vector"
app:tintDrawableEnd="@color/green"
app:drawableEnd="@drawable/ic_your_vector"
app:tintDrawableBottom="@color/yellow"
app:drawableBottom="@drawable/ic_your_vector"
... />
<style name="MyStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="tintCompound">@color/colorAccent</item>
<item name="drawableStart">@drawable/ic_your_vector</item>
</style>
<com.github.jeffersonrojas.viewutils.library.TextView
android:text="Hello world!"
style="@style/MyStyle" />
<com.github.jeffersonrojas.viewutils.library.Button
android:text="Hello world!"
style="@style/MyStyle" />
<com.github.jeffersonrojas.viewutils.library.EditText
android:text="Hello world!"
style="@style/MyStyle" />
Add your fonts without java.
- Create the
assets/fonts
folder, if you do not know how to create the assets folder you can follow this tutorial - Add your custom fonts to Android Studio like this, and you can start to use ViewUtils
- Set your custom font in xml or from styles, if your font is in format
.ttf
just addapp:font="amazing font"
, for other formarts you need addapp:fontType="otf"
<!-- Font format .otf -->
<com.github.jeffersonrojas.viewutils.library.TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Hello world!"
app:font="amazing font"
app:fontType="otf" />
<!-- Font for EditText -->
<com.github.jeffersonrojas.viewutils.library.EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world!"
android:hint="Hi"
app:font="amazing font" />
<!-- Font for Button -->
<com.github.jeffersonrojas.viewutils.library.Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:font="amazing font" />
<style name="MyStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="font">amazing font</item>
<item name="fontType">otf</item>
</style>
<!-- Font from style -->
<com.github.jeffersonrojas.viewutils.library.TextView
android:text="Hello world!"
style="@style/MyStyle" />
##License
Copyright 2017 Jefferson Rojas
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:https://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.