Android常用资源总结
16lz
2021-12-04
前言
在我们的日常开发当中,经常会使用到Android系统自带的资源,比如图片,主题,样式等等,所以我将一些常用的东西给总结了一下
1. 调用系统资源带有@和?,两者的区别如下:
-
调用系统的样式,主题,动画资源等一般以@开头
android:theme="@android:style/Theme.Dialog"android:interpolator="@android:anim/accelerate_decelerate_interpolator"
-
调用attr下的资源设置view的属性,一般以?开头
android:textColor="?android:attr/textColorPrimary" style="?android:attr/progressBarStyleLarge"
2. Toolbar高度
?attr/actionBarSize
3. Toast背景和字体设置
Toast toast = Toast.makeText(this, "", Toast.LENGTH_SHORT);//创建Toast对象toast.getView().setBackgroundColor(getResources().getColor(R.color.colorPrimary));//设置Toast背景TextView tvMessage = toast.getView().findViewById(android.R.id.message);tvMessage.setTextColor(getResources().getColor(R.color.colorPrimary));//设置Toast字体颜色
4. Snackbar背景和字体设置
Snackbar snackbar = Snackbar.make(view, "", Snackbar.LENGTH_SHORT);snackbar.getView().setBackgroundColor(getResources().getColor(R.color.colorPrimary));//设置Snackbar背景TextView tvSnackBarText = snackbar.getView().findViewById(R.id.snackbar_text);tvSnackBarText.setTextColor(getResources().getColor(R.color.colorPrimary));//设置Snackbar字体颜色
5. 系统自带视图动画
android.R.anim.fade_in,android.R.anim.fade_out//举个例子 有很多
6. 调用系统drawable
@android:drawable/btn_dialog
7. Button设置文字为英文时全部为大写,解决方法
方式一
android:textAllCaps="false"
方式二
android:textAppearance="?android:attr/textAppearance"
8. TabLayout英文状态下字母全部为大写的解决方法
app:tabTextAppearance="?android:attr/textAppearanceSmall"
9. 设置DatePicker为Spinner模式
后续持续更新...
更多相关文章
- andirons studio五大布局简介
- Android(安卓)Studio开发环境的搭建
- [Android][设置最小(大)宽高]
- android实现TextView多行文本滚动
- Android(安卓)TextView属性大全
- 深度解析Android中字体设置
- android实现TextView多行文本滚动
- Android中TextVIew一些属性
- Android(安卓)Interface Definition Language (AIDL) android接