首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在物料卡视图中不工作的相对布局。不能关闭相对布局标签

在物料卡视图中不工作的相对布局。不能关闭相对布局标签
EN

Stack Overflow用户
提问于 2022-08-15 06:25:50
回答 1查看 63关注 0票数 0

嗨,我是Android/XML的新手,我试图在材料卡片视图中创建相对布局,但是相对布局结束标签给了我错误的“关闭这个标签的错误方式”,并说用相对布局替换材料卡片视图。

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <ImageView
            android:layout_width="120dp"
            android:layout_height="170dp"
            android:id="@+id/bookimg"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@mipmap/ic_launcher"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/booktitle"
            android:text="Book Title"
            android:textSize="20sp"
            android:textColor="@color/white"
            android:textStyle="bold"/>


        </RelativeLayout>


</com.google.android.material.card.MaterialCardView>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-15 06:57:01

一定是这样的

代码语言:javascript
复制
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="120dp"
            android:layout_height="170dp"
            android:id="@+id/bookimg"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@mipmap/ic_launcher"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/booktitle"
            android:text="Book Title"
            android:textSize="20sp"
            android:textColor="@color/white"
            android:textStyle="bold"/>


        </RelativeLayout>


</com.google.android.material.card.MaterialCardView>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73357519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档