1. progressBar 颜色设置
a. xml 设置
android:progressTint="@color/purple_200"
对应示例图中 进度条的颜色已经被设置为紫色
b. 代码动态设置
batteryBar.setProgress(13); // 进度设置
batteryBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
2. FloatingActionButton
material floating-action-button
效果:
3. editText 失去焦点 收起软键盘
设置如下 OnFocusChangeListener 即可
private final class OnFocusChange implements View.OnFocusChangeListener {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if (!hasFocus) {
InputMethodManager manager = ((InputMethodManager) (PwdActivity.this).getSystemService(Context.INPUT_METHOD_SERVICE));
if (manager != null)
manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
4. RecylerView 下拉刷新
https://www.jianshu.com/p/f384032572d6
或者
SwipeRefreshLayout (官方, 效果如下)
配置: (把 RecylerView 包裹起来即可)
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/pwd_list_refresh_layout"
>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pwd_list_view" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
5. 全局字体设置
使用开源库 Calligraphy
然后修改所有 activity 的行为 (其余配置全局 style 的没成功过。。)