DrawerLayout

时间:2017-11-14 05:00:46

标签: android android-cardview drawerlayout

我正在尝试在drawerLayout上显示cardViews,如下所示: CardView

但最后一张CardView显示不正确。 我的cardView.xml代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
 <android.support.v7.widget.CardView   
  xmlns:android="http://schemas.android.com/apk/res/android"                                                       
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_margin="10dp"
  card_view:cardCornerRadius="4dp"
  card_view:cardElevation="10dp"
  android:layout_height="wrap_content">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Drinks"
        android:id="@+id/posTxt"
        android:padding="10dp"

        />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/image"
        android:padding="10dp"
        android:src="@drawable/ghost"
        android:layout_below="@+id/posTxt"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:text="Name"
        android:id="@+id/nameTxt"
        android:padding="10dp"
        android:textColor="@color/colorGreen"
        android:layout_below="@+id/image"

        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text=" This is the best drink"
        android:id="@+id/descTxt"
        android:padding="10dp"
        android:layout_below="@+id/nameTxt"
        android:layout_alignParentLeft="true"
        />



</RelativeLayout>

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

我的activity_main.xml代码如下所示:     

<android.support.v4.widget.DrawerLayout   
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/drawyerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"

tools:context="com.hasan.tablayout.MainActivity">


<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">



        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        </android.support.v7.widget.Toolbar>



        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>




    </android.support.design.widget.AppBarLayout>
    <include layout="@layout/content_main"/>



    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />

</android.support.design.widget.CoordinatorLayout>



<android.support.design.widget.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:menu="@menu/navigation_menu"
    android:layout_gravity="start"
    app:headerLayout="@layout/navigation_header"/>




</android.support.v4.widget.DrawerLayout>

我在我的xml代码中添加了card_view:cardCornerRadius,card_view:cardElevation。但我不明白我的错误在哪里?

0 个答案:

没有答案
相关问题