我有一个小三角形,指示用户是在注册还是登录屏幕中,但是三角形图像与其下面的RelativeLayout视图之间有一个很小的间隙
那将达到三角形所能达到的高度,而且我不确定如何仅将其增加1个像素以消除该烦人的间隙。这是我的XML
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorLightTan"
tools:context=".LoginActivity">
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="58dp"
android:background="@color/colorCoral"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relativeLayout"
app:layout_constraintVertical_bias="0.0">
<TextView
android:id="@+id/logintextBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="49dp"
android:layout_marginLeft="49dp"
android:layout_weight="1"
android:font="@font/americancaptain"
android:text="Login"
android:textColor="@color/colorBackground"
android:textSize="26dp"
app:fontFamily="sans-serif-condensed" />
<TextView
android:id="@+id/logintextBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="260dp"
android:layout_marginLeft="260dp"
android:layout_weight="1"
android:font="@font/americancaptain"
android:text="Register"
android:textColor="@color/colorBackground"
android:textSize="26dp"
app:fontFamily="sans-serif-condensed" />
<Button
android:id="@+id/registerButtonLogin"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:padding="0dp"
android:text=""
android:background="@android:color/transparent"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="79dp"
android:background="@color/colorBackground"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="53dp"
android:layout_marginLeft="53dp"
android:layout_marginBottom="-33dp"
android:layout_weight="1"
android:paddingBottom="0dp"
app:srcCompat="@drawable/halfhalf" />
</RelativeLayout>
<ImageView
android:id="@+id/imageView4"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="-20dp"
android:layout_marginEnd="6dp"
android:layout_marginRight="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.079"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relativeLayout2"
app:srcCompat="@drawable/triangle" />
<EditText
android:id="@+id/usernameLoginBox"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="112dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/edit_text_border"
android:ems="10"
android:hint=" Email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"
tools:textColor="@color/colorBackground" />
<EditText
android:id="@+id/passwordLoginBox"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="@drawable/edit_text_border"
android:ems="10"
android:hint=" Password"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usernameLoginBox"
tools:textColor="@color/colorBackground" />
<Button
android:id="@+id/signinButtonLogin"
android:layout_width="300dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@color/colorCoral"
android:text="LOGIN"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordLoginBox" />
</android.support.constraint.ConstraintLayout>
我尝试将marginTop设置为-20dp,以查看是否会提高它,但它无助于解决问题
答案 0 :(得分:0)
查看此
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorLightTan"
tools:context=".LoginActivity">
<FrameLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relativeLayout"
app:layout_constraintVertical_bias="0.0">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="58dp"
android:background="@color/colorCoral"
android:orientation="horizontal">
<TextView
android:id="@+id/logintextBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="49dp"
android:layout_marginLeft="49dp"
android:layout_weight="1"
android:font="@font/americancaptain"
android:text="Login"
android:textColor="@color/colorBackground"
android:textSize="26dp"
app:fontFamily="sans-serif-condensed" />
<TextView
android:id="@+id/logintextBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginStart="260dp"
android:layout_marginLeft="260dp"
android:layout_weight="1"
android:font="@font/americancaptain"
android:text="Register"
android:textColor="@color/colorBackground"
android:textSize="26dp"
app:fontFamily="sans-serif-condensed" />
<Button
android:id="@+id/registerButtonLogin"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:background="@android:color/transparent"
android:padding="0dp"
android:text="" />
</RelativeLayout>
<ImageView
android:id="@+id/imageView4"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginTop="50dp"
android:layout_marginLeft="35dp"
app:srcCompat="@drawable/triangle" />
</FrameLayout>
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="79dp"
android:background="@color/colorBackground"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="53dp"
android:layout_marginLeft="53dp"
android:layout_marginBottom="-33dp"
android:layout_weight="1"
android:paddingBottom="0dp"
app:srcCompat="@drawable/halfhalf" />
</RelativeLayout>
<EditText
android:id="@+id/usernameLoginBox"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="112dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/edit_text_border"
android:ems="10"
android:hint=" Email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relativeLayout2"
tools:textColor="@color/colorBackground" />
<EditText
android:id="@+id/passwordLoginBox"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="@drawable/edit_text_border"
android:ems="10"
android:hint=" Password"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usernameLoginBox"
tools:textColor="@color/colorBackground" />
<Button
android:id="@+id/signinButtonLogin"
android:layout_width="300dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="@color/colorCoral"
android:text="LOGIN"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordLoginBox" />
</android.support.constraint.ConstraintLayout>