我在学习《第一行代码 Android》时,书中介绍的百分比布局PercentFrameLayout
和PercentRelativeLayout
已经废弃,被androidx.percentlayout:percentlayout:1.0.0
替代。
开发环境:
macOS 10.16
Android Studio 4.0.1
书中代码如下:
修正代码:
// app\build.gradle
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
// 插入此行代码
implementation 'androidx.percentlayout:percentlayout:1.0.0'
//
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
<!--src/main/res/layout/activity_main.xml-->