简体   繁体   English

为什么ImageView会通过增加边距顶部尺寸来变得更小?

[英]Why does ImageView get smaller by increasing margin top size?

I have got a relative Layout in which I want to display one Imageview and one TextView with background-image . 我有一个相对的布局,我想在其中显示一个Imageview和一个带有background-image TextView

If I didn't use any margin-top it works how I should, but if I increase the top margin of the ImageView the Image gets smaller. 如果我不使用任何页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>

Use android:paddingTop="40dp" 使用android:paddingTop="40dp"

instead of marginTop 代替marginTop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM