12.15 写Android UI组件遇到问题

1.imeOptions :android键盘中的enter键图标是可以用EditText的android:imeOptions标签变更

android:ems = "10" : 设置TextView或者Edittext编辑的字符串长度为10,超出部分不显示,该属性只有android:layout_width=“wrap_content” 时才显示,是march_parent时不会有变化

android:layout_alignParentBottom="true"

2.遇到问题:

1)android:id="@id/bottomLine_1”报错Cannot resolve symbol '@id/bottomLine_1' 原因:id前少+

2)’B’ is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore报错  原因:文件名称不能有大写B

3)Execution failed for task ':app:processDebugResources'.

> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction

   > Android resource linking failed

     ERROR:/Users/Hannah/Desktop/Android/KTNews/app/src/main/res/layout/login.xml:30: AAPT: error: attribute android:textsize not found.

原因:大小写拼写问题

4)Execution failed for task ':app:mergeDebugResources'.

> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable

   > Resource compilation failed. Check logs for details.

ParseError at [row,col]:[17,53]

Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?TextView&app:layout_constraintBottom_toTopOf&app原因:fragment_first.xml里面的 <androidx.constraintlayout.widget.ConstraintLayout里面 xmlns:app="http://schemas.android.com/apk/res-auto"  这句去掉就会布局完全错乱报错Namespace’app’ is not bound

5)安卓的xml文件名不能含大写字母?java或Kotlin类文件名和属性名和对应的xml文件名和文件内控件id有关联,比如login.xml里面的xmlns:tools="http://schemas.android.com/tools"

tools:context=".FirstFragment”那么FirstFragment.java文件内的import com.example.ktnews.databinding.LoginBinding此处必须为Login 否则会报错

6)run安装报错:Installation did not succeed.

The application could not be installed.

List of apks:

[0] '/Users/Hannah/Desktop/Android/KTNews/app/build/outputs/apk/debug/app-debug.apk'

Installation failed due to: ''cmd package install-create -r -t --user current --full --dont-kill --skip-verification -S 3216623' returns error 'Unknown failure: cmd: Can't find service: package''

看到进程qemu-system-aarch64 占cpu300%多 清理进程,wipe Data模拟器后重新运行解决

7)Touch size is too small This item's height is 25dp. Consider making the height of this touch target 48dp or larger.  suggestion不是错误可以ignore

8)只有Button的background颜色设置成自定义的xml无效,而是受themes影响,而自定义xml里的corner有效 目前没解决 应该怎么解决或别的替换方式?

解决办法:找到res/values目录下的themes.xml将里面的

<style name="Theme.UICustomViews" parent="Theme.MaterialComponents.DayNight.DarkActionBar">改成

<style name="Theme.UICustomViews" parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge">

3.疑问:

1.Android 布局巧用之include、merge、ViewStub 2.baselineAligned这是干啥的呢?设置成true或false都没用

  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值