- Xml drawable
- Tiling background
- Text
- Text shadow
- Gradient
- Custom font
- Icon font
rectangle
oval
line
ring
res/drawable/rectangle.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#f00" /> </shape>
res/layout/activity_main.xml
<View android:layout_width="120dp" android:layout_height="80dp" android:background="@drawable/rectangle" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#0f0"
android:endColor="#00f" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#0f0"
android:endColor="#00f"
android:angle="270" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#0f0"
android:endColor="#00f"
android:angle="270" />
<corners android:radius="15dp" />
</shape>
res/drawable/button.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:drawable="@drawable/button_pressed" /> <item android:state_focused="true" android:drawable="@drawable/button_focused" /> <item android:drawable="@drawable/button_normal" /> </selector>
res/drawable/button_pressed.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#D0B5DF" android:endColor="#9357B5" android:angle="270" /> <corners android:radius="5dp" /> </shape>
res/drawable/text.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:color="#000" /> <item android:state_focused="true" android:color="#fff" /> <item android:color="#fff" /> </selector>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@drawable/text"
android:background="@drawable/button"
android:text="@string/ok" />
clamp Replicates the edge color |
|
repeat Repeats the bitmap in both direction |
|
mirror Repeats with alternating mirror images |
<View xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/tile_background" />
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/tile"
android:tileMode="mirror"
android:dither="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="48sp" android:shadowColor="#fff" android:shadowDx="5" android:shadowDy="-5" android:shadowRadius="5" android:textColor="#f00" android:text="Text Shadow" />
Shader shader = new LinearGradient(
0, 0, 0, textView.getTextSize(),
Color.RED, Color.BLUE,
Shader.TileMode.CLAMP);
textView.getPaint().setShader(shader);
Shader shader = new LinearGradient( 0, 0, 0, textView.getTextSize(), Color.RED, Color.BLUE, Shader.TileMode.MIRROR); Matrix matrix = new Matrix(); matrix.setRotate(45); shader.setLocalMatrix(matrix); textView.getPaint().setShader(shader);
Typeface typeface = Typeface.createFromAsset( getAssets(), "Ruthie.ttf"); textView.setTypeface(typeface);
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="144sp" android:text="@string/icon_android" />
public class IconTextView extends TextView { public IconTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } private void init() { Typeface typeface = Typeface.createFromAsset( getContext().getAssets(), "icomoon.ttf"); setTypeface(typeface); Shader shader = new LinearGradient(0, 0, 0, getTextSize(), Color.LTGRAY, Color.DKGRAY, Shader.TileMode.CLAMP); getPaint().setShader(shader); } }
<com.sqisland.android.IconFontView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="144sp" android:text="@string/icon_android" />
public class TintedButton extends Button { public TintedButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } private void init() { getBackground().setColorFilter( new LightingColorFilter(0xFFCCCCCC, 0xFFA40000)); } }
<com.sqisland.android.TintedButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/start_timer" />
Normal | Pressed | |
---|---|---|
Default | ||
Tinted | ||
Default (older) | ||
Tinted (older) |
#33B4E5
<link href='http://fonts.googleapis.com/css?family=Ruthie' rel='stylesheet' type='text/css'>
@font-face { font-family: 'Ruthie'; font-style: normal; font-weight: 400; src: local('Ruthie'), local('Ruthie-Regular'), url(http://themes.googleusercontent.com/something) format('woff'); }
Convert woff
to ttf
or otf
.
<string name="icon_fontello_sunny">1</string> <string name="icon_fontello_rainy">8</string> <string name="icon_fontello_cloudy">N</string> <string name="icon_fontello_bicycle">B</string> <string name="icon_fontello_coffee">C</string>
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html
svg
→ png
convert \ -density 100 \ -background none \ -trim \ cat.svg cat.png
convert
.
Upload your own svg e.g. from The Noun Project
<string name="icomoon_camera">C</string> <string name="icomoon_water">W</string> <string name="icomoon_teapot">T</string>