我對 GuideLine 有疑問,有人知道解決方案嗎?
看起來該指南缺少課程
找不到以下類: - android.support.constraint.Guideline(修復構建路徑、編輯 XML、創建類)
點擊按鈕后的Logcat:
準則問題
XML 代碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="350dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline <!-- THAT'S THE PROBLEM -->
android:id="@ id/guideline"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
<!-- ... here are more similar textView's -->
<TextView
android:id="@ id/tv_batteryDrainNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="0"
android:textStyle="bold"
android:textSize="25sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@ id/guideline"
app:layout_constraintTop_toBottomOf="@ id/tv_batteryDrain" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
構建 Gradle:
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.3'
implementation 'com.google.firebase:firebase-database:20.0.4'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.github.anastr:speedviewlib:1.5.4'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
uj5u.com熱心網友回復:
嘗試使用androidx.constraintlayout.widget.Guideline而不是android.support.constraint.Guideline
<androidx.constraintlayout.widget.Guideline
android:id="@ id/guideline"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/459330.html
上一篇:將決議的XML結果寫入CSV
下一篇:如何向XML添加新行
