必須說(shuō)下6.0里面的新控件
1 FloatingActionButton
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
默認(rèn)背景顏色是AppTheme中colorAccent的值盹牧,如果要修改背景可以用
app:backgroundTint="@color/colorPrimary"
使用android:background="@color/colorPrimary"會(huì)報(bào)錯(cuò)俩垃,在API>19無(wú)陰影效果
加入
app:borderWidth="0dp"
2 TextInputLayout
device-2016-05-10-202419.png
TextInputLayout繼承了LinearLayout,所有要在布局里面加入EditText汰寓。下劃線的顏色依然是AppTheme中colorAccent的值
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
3 Snackbar
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
使用方式和Toast一樣吆寨,但是效果好看多了。