2016-06-15 89 views

回答

0

在我與Visual Studio .axml編輯的經驗,這些警告會直接使用支持庫窗口小部件的LinearLayout或RelativeLayout的內部時出現。但是,它們通常不會影響構建和運行代碼的能力。

在下面的代碼中,SwipeRefreshLayout與您獲得的警告相同,而ViewSwitcher內部的RecyclerView沒有。如果RecyclerView被移動到LinearLayout中,它將顯示相同的警告,但代碼仍然可以正確編譯。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/very_light_gray"> 
<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeRefreshLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/middle_gray"> 
    <ViewSwitcher 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/switcher" 
     android:background="@color/middle_gray"> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/paperworkRecyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
     <TextView 
      android:id="@+id/text_empty" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:text="No Load Offers Available" 
      android:background="@color/middle_gray" 
      android:gravity="center" /> 
    </ViewSwitcher> 
</android.support.v4.widget.SwipeRefreshLayout> 

如果你有問題或建築物運行的代碼,請確保您有RecyclerView支持包,它依賴於Support.v4包的匹配版本,並提供有關錯誤的詳細信息你在建立/運行。