Android:CardView 即将推出操作栏

标签 android xml android-recyclerview android-actionbar android-cardview

我用过recycler View来展示CardView。我在抽屉导航 Main Activity 中完成了此操作。但是我的卡片 View 显示在操作栏上。

app_bar_main

<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"
tools:context="kb.niranjan.tvseries.MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/AppTheme.PopupOverlay" />

    <include layout="@layout/content_main" />

</RelativeLayout>

内容菜单

<android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cv"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="5dp"
android:layout_margin="08dp"
xmlns:android="http://schemas.android.com/apk/res/android"
card_view:cardBackgroundColor="#263238"
>

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

    <ImageView
        android:layout_width="41dp"
        android:layout_height="58dp"
        android:id="@+id/person_photo"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="16dp"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/person_name"
        android:layout_toRightOf="@+id/person_photo"
        android:layout_alignParentTop="true"
        android:textSize="30sp"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/person_age"
        android:layout_toRightOf="@+id/person_photo"
        android:layout_below="@+id/person_name"
        />

</RelativeLayout>

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

我想在 ActionBar 下面显示我的卡片

最佳答案

改变你的app_bar_main

<LinearLayout 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:orientation="vertical"
    android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary" />

<include layout="@layout/content_main" />

</LinearLayout>

关于Android:CardView 即将推出操作栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44870289/

相关文章:

java - 如果没有调试,为什么 Android Studio 会显示 "Waiting For Debugger"?

java - 如何使用java/python从xml结构中获取匹配xpath的DOM结构

android - 可以为两种 View 类型使用一个 viewholder 吗?

android - 如何将 videoView 与 imageView 和 recyclerView 一起制作动画?

java - 跨应用程序可用的方法?

android - VideoView 不会缩放内容以匹配其父项

java - 在应用程序启动时播放声音

java - Ant - 没有公共(public)执行()错误,即使它存在

html - 如何在 Xpath 中将两个节点合并为一组?

android - 如何使座位布局像redbus?