我有一个相对布局,我想在其中显示一个 Imageview
和一个带有 background-image
的 TextView
。
如果我没有使用任何margin-top
,它会按照我应该的方式工作,但是如果我增加 ImageView 的上边距,图像就会变小。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/playerNameEnd"
android:layout_width="200dp"
android:layout_height="80dp"
android:background="@drawable/casino2"
android:gravity="center"
android:text="Player"
android:textColor="@color/cream"
android:textSize="26sp" />
<ImageView
android:id="@+id/roulette_EndPic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
app:srcCompat="@drawable/casino" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
最佳答案
使用android:paddingTop="40dp"
而不是 marginTop
关于java - 为什么增加边距顶部尺寸后 ImageView 会变小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48894579/