【发布时间】:2021-03-13 18:50:43
【问题描述】:
我正在使用 RecyclerView 为 Linear Vertical listViews 充气,但是,虽然子项的宽度设置为 match_parent,但 RecyclerView 在运行时将其包装起来。
这是问题的截图:
item_recyclerView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tag_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:maxLines="2"/>
<TextView
android:id="@+id/tag_role"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/user_pic"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="0"
android:rotation="-45"
android:scaleType="centerCrop"
android:src="@drawable/ic_user"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.circleImageView" />
</LinearLayout>
【问题讨论】:
-
你在
item_recyclerView的第一个LinearLayout上尝试过android:layout_weight="1"吗?
标签: android android-fragments android-recyclerview android-linearlayout android-framelayout