安裝 android studio 后,我想創建一個測驗應用程式,所以我只在默認的 hello world 應用程式中添加了一個按鈕并運行它,但我收到了這個錯誤。(在搜索stackoverflow類似的問題和解決方案后,我問了一個問題......)
AAPT: error: '???dp' is incompatible with attribute layout_marginEnd (attr) dimension.
這是android studio自動生成的代碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@ id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello world!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@ id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="??dp"
android:layout_marginEnd="???dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@ id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
uj5u.com熱心網友回復:
您已將阿拉伯數字用于android:layout_marginTop="??dp"&&android:layout_marginEnd="???dp"使用英文編號,例如"10dp"
uj5u.com熱心網友回復:
改變這個: android:layout_marginTop="32dp" android:layout_marginEnd="???dp" 到: android:layout_marginTop="5dp" android:layout_marginEnd="5dp"
(在Button標簽內)
uj5u.com熱心網友回復:
用非英語書寫的數字可能會因更改而更正
android:layout_marginTop="32dp"
android:layout_marginEnd="180dp"
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/407461.html
標籤:
