如何使用android studio中的recycler视图来制作这样的布局。我不能得到确切的输出。
以下是我的示例图像:
这是我的回收器视图代码示例。如果低于卡片视图布局,我看不到图像
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" />
发布于 2018-08-03 04:05:12
如果我正确理解了您的问题,您希望ImageView位于CardView之上。这可以通过简单地切换FrameLayout中的位置来实现。在FrameLayout中,第二个子项(布局)显示在第一个子项的上方,第三个子项显示在第二个子项的上方,依此类推。在XML中或在层次结构中,将ImageView放在CardView下将导致图像显示在CardView的上方。
https://stackoverflow.com/questions/51658763
复制相似问题