你好,我想在我的應用程式中放置一個TextView,但當我拖動它時,會發生這種情況。我已經添加了樣式和布局xmls
。如果有任何新手錯誤,請原諒我,我是個新手
。我的theme.xml檔案中的內容是:"在此輸入圖片描述。
我的主題.xml檔案:
<資源 xmlns:tools="http://schemas.android.com/tools">
<!--基礎應用主題。-->
<style name="AppTheme" parent="@style/Theme.AppCompat.DayNight.NoActionBar" />
<style name="AppBgTheme"/span> parent="@style/AppTheme"/span>>
<專案名稱="android:windowBackground">@drawable/launcher_bg</item>。
<專案名稱="android:statusBarColor">@android:color/transparent</item>
<專案名稱="android:navigationBarColor">@android:color/transparent</item>
<專案名稱="android:fontFamily">sans-serif-medium</item>
</style>
<style name="RobotoTextViewStyle" parent="@android:style/Widget.TextView">
<專案名稱="android:fontFamily">sans-serif-light</item>
</style>
<style name="Platform.ThemeOverlay.AppCompat.Dark" parent="@style/Platform.ThemeOverlay.AppCompat" />
<style name="Platform.ThemeOverlay.AppCompat.Light" parent="@style/Platform.ThemeOverlay.AppCompat" />
</resources>
layout xml:
<?xml version="1.0"/span> encoding="utf-8"/span>?
<androidx.constraintlayout.widget.ConstraintLayout xmlns:tools="http://schemas.android.com/tools"?
android:layout_gravity="center"/span>
android:id="@id/activity_main"/span>
android:padding="6.0dip"/span>
android:layout_width="match_parent"/span>
android:layout_height="match_parent"/span>
xmlns:android="http://schemas.android.com/apk/res/android"/span>
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@ id/textView111"/span>
android:layout_width="wrap_content"/span>
android:layout_height="wrap_content"。
android:text="@string/app_name"/span>
android:textColor="#00AAFF"/span>
android:textSize="36sp"/span>
app:layout_constraintBottom_toBottomOf="parent"。
app:layout_constraintEnd_toEndOf="parent"。
app:layout_constraintStart_toStartOf="parent"。
app:layout_constraintTop_toTopOf="parent"。
app:layout_constraintVertical_bias="0.442"/span> />
</androidx.constraintlayout.widget.ConstraintLayout>
uj5u.com熱心網友回復:
在@id/activity_main中的id旁邊添加了一個 ,表示這個id還沒有被識別,是第一次提到。
<?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_gravity="center"
android:id="@ id/activity_main"
android:padding="6.0dip"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@ id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="#00AAFF"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="父級"
app:layout_constraintEnd_toEndOf="父級"
app:layout_constraintStart_toStartOf="父級"
app:layout_constraintTop_toTopOf="父級"
app:layout_constraintVertical_bias="0.442" />
</androidx.constraintlayout.widget.ConstraintLayout>
如果這還不能解決你的問題,請檢查你的build.gradle(Module:app),可能你沒有添加androidx約束布局的依賴,這就是為什么你的布局不能識別它。
dependencies {
...
實作 'androidx.constraintlayout:constraintlayout:2.1.0' 。
...
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/327619.html
標籤:

