这是我的布局代码
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include"
layout="@layout/app_bar"
android:layout_width="0dp"
android:layout_height="90dp"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="parent" />
<fragment
android:id="@+id/activity_home_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toBottomOf="@id/include" />
<android.support.v7.widget.CardView
cardElevation="3dp"
cardUseCompatPadding="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="75dp"
android:backgroundTint="@android:color/holo_blue_bright"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@+id/include">
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/activity_home_view_green"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="20dp"
android:background="@drawable/circle"
map:layout_constraintBottom_toBottomOf="@+id/textView3"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:text="My Location"
map:layout_constraintBottom_toTopOf="@+id/guideline3"
map:layout_constraintStart_toEndOf="@+id/activity_home_view_green"
map:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintHorizontal_bias="0.0"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@id/guideline3" />
<View
android:id="@+id/activity_home_view_gray"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:background="@drawable/circle1"
map:layout_constraintBottom_toBottomOf="@+id/activity_home_et"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toBottomOf="@+id/view3" />
<EditText
android:id="@+id/activity_home_et"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="40dp"
android:hint="Where are you going?"
android:textColor="@android:color/black"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toEndOf="@+id/activity_home_view_gray"
map:layout_constraintTop_toTopOf="@+id/guideline3" />
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
map:layout_constraintGuide_begin="50dp" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<pritish.sawant.com.androiddevslopesuberclone.CustomProgressBarInButton.CircularProgressButton
android:id="@+id/activity_home_request_ride_btn"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="@drawable/button_background"
android:gravity="center"
android:text="REQUEST RIDE"
android:textSize="20sp"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
tools:fontFamily="@font/changa_one" />
<ImageView
android:id="@+id/activity_home_iv_centerme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:scaleType="centerInside"
map:layout_constraintBottom_toTopOf="@+id/activity_home_request_ride_btn"
map:layout_constraintEnd_toEndOf="parent"
map:srcCompat="@mipmap/centermapbtn" />
</android.support.constraint.ConstraintLayout>
我从卡片视图中删除了一些与问题无关的不需要的视图。我尝试为卡片视图的背景设置不同的颜色,以避免edittext
和cardview
之间的颜色冲突,但仍然不可见。我甚至尝试删除卡片视图,但我的编辑文本中的文字仍然不可见。
问题是你已经将EditText
的高度设置为20dp。将EditText
的高度设为wrap_content
,您将看到您的文字/提示。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include"
android:layout_width="0dp"
android:layout_height="90dp"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="parent" />
<fragment
android:id="@+id/activity_home_map"
android:layout_width="match_parent"
android:layout_height="0dp"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toBottomOf="@id/include" />
<android.support.v7.widget.CardView
cardElevation="3dp"
cardUseCompatPadding="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="75dp"
android:backgroundTint="@android:color/holo_blue_bright"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@+id/include">
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/activity_home_view_green"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="20dp"
android:background="@drawable/contact_us"
map:layout_constraintBottom_toBottomOf="@+id/textView3"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:text="My Location"
map:layout_constraintBottom_toTopOf="@+id/guideline3"
map:layout_constraintStart_toEndOf="@+id/activity_home_view_green"
map:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintHorizontal_bias="0.0"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="@id/guideline3" />
<View
android:id="@+id/activity_home_view_gray"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:background="@drawable/bg_counter"
map:layout_constraintBottom_toBottomOf="@+id/activity_home_et"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toBottomOf="@+id/view3" />
<EditText
android:id="@+id/activity_home_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="40dp"
android:hint="Where are you going?"
android:textColor="@android:color/black"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toEndOf="@+id/activity_home_view_gray"
map:layout_constraintTop_toTopOf="@+id/guideline3" />
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
map:layout_constraintGuide_begin="50dp" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<pritish.sawant.com.androiddevslopesuberclone.CustomProgressBarInButton.CircularProgressButton
android:id="@+id/activity_home_request_ride_btn"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="@drawable/button_background"
android:gravity="center"
android:text="REQUEST RIDE"
android:textSize="20sp"
map:layout_constraintBottom_toBottomOf="parent"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
tools:fontFamily="@font/changa_one" />
<ImageView
android:id="@+id/activity_home_iv_centerme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:scaleType="centerInside"
map:layout_constraintBottom_toTopOf="@+id/activity_home_request_ride_btn"
map:layout_constraintEnd_toEndOf="parent"
map:srcCompat="@drawable/exit" />
</android.support.constraint.ConstraintLayout>