Android Studio 版本3.4.2
Android 版本最高9.0
更换APP的应用图标
从android7.0开始,android开始使用圆角图标
在新版AS中,模拟器Android版本已经普及到了7.0。所以如果更改AndroidManifest.xml 里面的android:icon 属性你会发现怎么更新都没用
现在需要更换android:roundIcon 属性,来进行APP图标的更换
图片必须为.png格式,把 icon.png copy到mipmap文件夹里,然后找到AndroidManifest.xml(app->src->main->AndroidManifest.xml) 更改 android:roundIcon="@mipmap/icon" ,然后你就会发现图标更改成功了
android:icon="@mipmap/icon"
android:roundIcon="@mipmap/icon">
为什么模拟器桌面会会出现两个APP图标
- 首先检查项目的AndroidManifest文件中是不是注册了两个Activity启动类型为Launcher
三种动画
- 旋转动画RotateAnimation
public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
参数1:float fromDegrees 开始旋转角度
参数2:float toDegrees 结束旋转角度
参数3:int pivotXType X轴起始点类型
- 如RotateAnimation.RELATIVE_TO_SELF | RELATIVE_TO_PARENT | ABSOLUTE
参数4:float pivotXValue X轴起始点值
参数5:int pivotYType Y轴起始点类型
参数6:float pivotYValue Y轴起始点值
对pivotXValue 和pivotYValue参数来说
image.png
Animation类
方法
public void setFillAfter(boolean fillAfter)
//fillAfter设置为true时,表示元素在动画结束后将实现动画结束后的效果
错误
- 在编译时出现下面这句错误
Invalid escape sequence at line 1 column 29 path $[0].name
这里的错误是因为项目中有中文字符,需要在项目下 gradle.properties 文件中添加以下代码
示意如下org.gradle.jvmargs = -Dfile.encoding=UTF-8
image.png
- 在编译时出现下面这句错误
android.view.InflateException: Binary XML file line #0: Error inflating class TextView
这是因为想实现button按钮的点击效果,在xml文件中引用了selcector
而在selector.xml文件中写的是 android:color,需要改为 android:drawableandroid:background="@drawable/btn_start_main_selector" android:textColor="@drawable/btn_start_main_textcolor_selector"
image.png