Android快速开发

颜色

1
2
3
4
<color name="colorPrimary">#33aaff</color>
<color name="colorPrimaryDark">#2299ee</color>
<color name="colorPrimaryOverlay">#cc0094ff</color>
<color name="colorAccent">#FF4081</color>

Toolbar

1
2
3
4
5
6
7
8
9
10
11
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
app:title="Title"
app:titleTextColor="#FFF"
app:navigationIcon="?attr/homeAsUpIndicator"
>

</android.support.v7.widget.Toolbar>

按钮

btn_normal.xml

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorPrimary"/>
<corners android:radius="5dp"/>
<padding android:top="2dp" android:bottom="2dp"/>
</shape>

btn_pressed.xml

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorPrimaryDark"/>
<corners android:radius="5dp"/>
<padding android:top="2dp" android:bottom="2dp"/>
</shape>

btn_selector.xml

1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/btn_pressed"/>
<item android:drawable="@drawable/btn_normal"/>
</selector>

引用

1
2
3
4
5
6
7
8
9
10
11
12
<Button
android:onClick="test"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/btn_selector"
android:text="测试"
android:textColor="#FFF"
android:textSize="16sp"
android:textAllCaps="false"
/>

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :