2016-03-02 229 views
3

對於我的main_activity,佈局預覽在調試後消失。Android Studio佈局預覽消失

我有2個其他layouts在這個項目中,我可以完美地看到預覽中的佈局。

的組件另樹說:沒有顯示
有沒有渲染錯誤顯示出來,下面是XML

enter image description here

感謝您的幫助!

問候 邁克爾

+0

先點擊刷新按鈕,檢查你的佈局文件 – Inducesmile

+0

是否有錯誤已經試過,但沒有錯誤..我沒有改變任何在xml代碼.. – Michael

+0

嗨邁克爾。偶爾遇到同樣的問題,沒有任何合理的原因。你有沒有找到解決辦法? –

回答

2

你試過重建項目,重新開放的Android工作室,廢止緩存?那就是如果你確定你什麼都沒做,它就消失了。

如果這不起作用,您可以嘗試將XML代碼保存在txt文件中,刪除xml佈局,創建一個空的代碼並粘貼代碼。

更新: 如果你環繞你的LinearLayout與滾動型,然後移動app:layout_behavior="@string/appbar_scrolling_view_behavior"到了滾動代替。我認爲一切都應該正常工作。

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     your ImageView and TextViews here 
    </LinearLayout> 
</ScrollView> 
-3

我也遇到了這個問題,但我通過修改build.gragle文件中的配置來解決這個問題:

enter image description here

enter image description here

+0

請修復「在這裏輸入圖片描述」 –

1

你可能已經看到,你不能在「組件樹」中看到任何東西,並且沒有在「屬性」部分顯示,並且在仿真器的預覽中顯示「android..ComponentLayout」。

我自己曾嘗試不同的方法,但發現最便捷的方法,只刪除了3行代碼在Main_Activity.xml文件,也可以直接粘貼下面的代碼或將其與這一個比較:

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 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" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
> 

0

我找到了解決方案。事實上,在android studio中存在一個bug。在我的情況下,問題是當我從「屬性」窗口啓用tabStripEnabled時,組件樹顯示「Nothing to show」,當我禁用它時,一切都恢復良好。 所以我通過編程編碼解決了這個問題:

tabHost.getTabWidget()。setStripEnabled(true);

所以我認爲你應該逐個檢查一切,以找到解決方案。 我希望這可能會有所幫助。

相關問題