美文网首页
Android Studio--项目实战中的坑

Android Studio--项目实战中的坑

作者: 蓝翼Ethan | 来源:发表于2019-08-21 10:29 被阅读0次

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图标

  1. 首先检查项目的AndroidManifest文件中是不是注册了两个Activity启动类型为Launcher

三种动画

  1. 旋转动画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时,表示元素在动画结束后将实现动画结束后的效果

错误

  1. 在编译时出现下面这句错误
Invalid escape sequence at line 1 column 29 path $[0].name

这里的错误是因为项目中有中文字符,需要在项目下 gradle.properties 文件中添加以下代码

 org.gradle.jvmargs = -Dfile.encoding=UTF-8
示意如下 image.png
  1. 在编译时出现下面这句错误
android.view.InflateException: Binary XML file line #0: Error inflating class TextView

这是因为想实现button按钮的点击效果,在xml文件中引用了selcector

android:background="@drawable/btn_start_main_selector"
android:textColor="@drawable/btn_start_main_textcolor_selector"
而在selector.xml文件中写的是 android:color,需要改为 android:drawable image.png

相关文章

网友评论

      本文标题:Android Studio--项目实战中的坑

      本文链接:https://www.haomeiwen.com/subject/xxzmsctx.html