我是 Android 開發新手,我正在嘗試制作一張簡單的生日快樂卡。每當我啟動應用程序并創建一個新項目時,我都會在 Activity_Main.xml 文件中收到一些錯誤,這些錯誤使我無法看到預覽。我嘗試過重新安裝 Java、重新安裝 Android Studio、檢查代理、將布局從約束更改為相對以及打開和關閉 XML 文件。<RelativeLayout xmlns:android="schemas.android.com/apk/res/android" xmlns:tools="schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent" tools:context=".MainActivity"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Happy Birthday YOURFRIENDHERE" /></RelativeLayout>給出的代碼只是在手機屏幕上顯示文本,但我一直收到所有屬性的錯誤,Android:layout、Tools:context 和 TextView 說它們是不允許的。即使我創建一個新項目并且沒有編輯任何內容,我仍然會在自動填充的代碼中遇到錯誤。
3 回答

qq_笑_17
TA貢獻1818條經驗 獲得超7個贊
嘗試這個
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Happy Birthday YOURFRIENDHERE" />
</RelativeLayout>

絕地無雙
TA貢獻1946條經驗 獲得超4個贊
我認為這是因為你的 android studio 的版本不是最新的,因為我認為當你發現你阻止通過你的互聯網從互聯網下載 gradle 資源時,谷歌希望我們使用最新版本。
添加回答
舉報
0/150
提交
取消