首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何创建这样的布局

如何创建这样的布局
EN

Stack Overflow用户
提问于 2018-08-03 00:56:50
回答 1查看 39关注 0票数 -1

如何使用android studio中的recycler视图来制作这样的布局。我不能得到确切的输出。

以下是我的示例图像:

这是我的回收器视图代码示例。如果低于卡片视图布局,我看不到图像

代码语言:javascript
复制
FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_gravity="top"
android:paddingTop="20dp"
android:orientation="horizontal">
<ImageView
    android:id="@+id/profile_photo"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:paddingTop="20dp"
    android:layout_gravity="bottom|end"
    android:contentDescription="@string/cd_profile_picture"
    android:scaleType="center"
    android:src="@mipmap/ic_launcher_round"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="0dp" />



<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    card_view:cardUseCompatPadding="true"
    card_view:cardBackgroundColor="@android:color/white">




<TextView
    android:id="@+id/comment_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:layout_marginStart="50dp"
    android:textColor="@color/black"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="0dp"
    tools:text="me" />
EN

回答 1

Stack Overflow用户

发布于 2018-08-03 04:05:12

如果我正确理解了您的问题,您希望ImageView位于CardView之上。这可以通过简单地切换FrameLayout中的位置来实现。在FrameLayout中,第二个子项(布局)显示在第一个子项的上方,第三个子项显示在第二个子项的上方,依此类推。在XML中或在层次结构中,将ImageView放在CardView下将导致图像显示在CardView的上方。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51658763

复制
相关文章

相似问题

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