![](/img/trans.png)
[英]I cant see textview and other elements layout android studio in activity_main.xml
[英]Can't see elements layout android studio in activity_main.xml
我從 android studio 開始,我看不到元素(按鈕,TextView,..)我拖放到我的設計頁面中的activity_main.xml
頁面。 這些元素存在於我的 XML 文件中,當我在我的設備上運行我的應用程序時我可以看到它們,但我不知道如何在“設計和藍圖”頁面上看到它們。
謝謝你的幫助。
這是我的 xml 代碼:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="25dp">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_home"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/navigation" />
<Button
android:id="@+id/button"
android:layout_width="12dp"
android:layout_height="12dp"
android:text="ClickMe"
tools:layout_editor_absoluteX="-73dp"
tools:layout_editor_absoluteY="29dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="20dp" />
</android.support.constraint.ConstraintLayout>
我的畫布完全是空的。
編輯 :
我有 2 個錯誤:
渲染問題: Failed to find style 'bottomNavigationStyle' in current theme Tip: Try to refresh the layout.
ConstraintLayout 中缺少約束: This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints
解決這個問題:
1)嘗試使用頂部構建菜單中的選項清理項目
2) 嘗試通過選擇 File 菜單中的選項使 Android Studio 無效並重新啟動
3)嘗試通過選擇頂部構建菜單中的選項來重建項目
我已經解決了這個問題:
我的 build.gradle 文件:
dependencies {
api 'com.android.support:appcompat-v7:28.0.0-alpha1'
api 'com.android.support:design:28.0.0-alpha1'
api 'com.android.support.constraint:constraint-layout:1.1.2'
api 'com.android.support:support-vector-drawable:28.0.0-alpha1'
application project(':app')
feature project(':feature')
}
我已將所有帶有“alpha3”的行更改為“alpha1”。 謝謝@hossein-seifi
在 Values.(res>>Values>>Styles.xml) 中找到Styles.xml
改變這個
添加“基地”
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to this:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
然后清理並構建項目。 您可以從構建菜單中執行這兩項操作。
它對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.