2015-09-02 2 views
0

Я пытаюсь реализовать дизайн CardView в своем коде; однако, я получаю сообщение об ошибке, которое указывает, что TextView и RelativeLayout здесь не разрешены.Ошибка Android CardView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.CardView 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="16dp" 
      style="@style/ItemBackground"> 

     <TextView android:text="@string/weather" 
      android:id="@+id/weather_header" 
      style="@style/ItemHeader" /> 

     <TextView 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/weather_header" 
      android:textSize="32sp" 
      android:textColor="#000000" /> 

     </RelativeLayout> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 
+0

Вы положили '' com.android.support:cardview-v7: + ''в свой град? –

+0

да, у меня есть компиляция 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:cardview-v7:+' –

+0

попробуйте удалить стиль из относительного и текстового просмотра и посмотреть, работает. –

ответ

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
android:orientation="vertical"> 

<android.support.v7.widget.CardView 

    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="16dp"> 

     <TextView android:text="weather" 
      android:id="@+id/weather_header" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 

     <TextView 
      android:text="ABCDEF" 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/weather_header" 
      android:textSize="32sp" 
      android:textColor="#000000" /> 

    </RelativeLayout> 
</android.support.v7.widget.CardView> 

Он работает в настоящее время. Я не заметил никакой ошибки к этому макету http://i.stack.imgur.com/SE8qk.png Что касается вопроса о текстовом виде. Вы потеряли, чтобы добавить высоту и ширину раскладки.

Смежные вопросы