《第一行代码》百分比布局中support包的问题

mac2026-08-11  8

因为我的Android studio更新过,所以support包不能用,我在网上找了好久,好像说是androidx代替了support,所以书上的代码要稍作修改: 1、

compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:percent:24.2.1'

需改为

implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:percent:28.0.0'

这里28.0.0是因为我的compileSdkVersion 28

2、布局文件中书上原本用的是android.support.percent.PercentRelativeLayout 这里要改为androidx.percentlayout.widget.PercentFrameLayout

3、别忘了加上xmlns:app="http://schemas.android.com/apk/res-auto"

4、原书的 也要改为

最新回复(0)