【发布时间】:2018-06-23 21:39:14
【问题描述】:
我有下面的 xml:
<RelativeLayout
android:id="@+id/relative_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/relative_two"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_product_imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
<TextView
android:id="@+id/status_product_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left"
android:layout_marginTop="20dp"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:visibility="invisible" />
</RelativeLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/relative_three"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_below="@+id/relative_two">
<Spinner
android:id="@+id/select_spinner"
android:layout_width="15dp"
android:layout_height="0dp"
android:layout_marginRight="5dp"
android:dropDownVerticalOffset="40dp"
android:gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/name_product_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:ellipsize="marquee"
android:gravity="right"
android:maxLines="1"
android:text="TEXT"
app:layout_constraintRight_toLeftOf="@+id/select_spinner"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/count_products_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="right"
android:text="TEXT"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/select_spinner"
app:layout_constraintTop_toBottomOf="@+id/name_product_textview" />
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
在上面xml我有下面ImageView:
<ImageView
android:id="@+id/image_product_imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
问题:我的ImageView不要match在cardView(左右和顶部)。它在ImageView周围有2或3个空格(左右和顶部) )。
在我的源代码中,我将图像设置如下:
Picasso.with(context)
.load(productsModelList.getPictureUrl())
.placeholder(AppCompatDrawableManager.get().getDrawable(context, R.drawable.placeholder_pictures))
.fit()
.into(image_product_imageview);
【问题讨论】:
-
关于问题的截图?
-
请检查您的布局文件是否有填充。 id 为 relative_one 的布局的宽度属性为“wrap_content”,其内部子元素的宽度属性为“match_parent”。你不认为它们相互混淆吗?
标签: android xml android-layout android-cardview android-relativelayout