我创建了一个包含一些编辑文本,日历的xml。我有一个问题,当我触摸编辑文本时,光标没有聚焦。我已经尝试了android:focusable = true在xml和java.but它不工作。我无法在编辑文本中键入值。这里是我的代码。
<?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/black">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_layout" />
<ScrollView
android:id="@+id/svScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintBottom_toTopOf="@+id/btUpdate"
>
<android.support.constraint.ConstraintLayout
android:id="@+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
>
<EditText
android:id="@+id/etEmailid"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/profile_background"
android:hint="@string/email_txt"
android:padding="10dp"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:inputType="text" />
<EditText
android:id="@+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/First_name"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etEmailid"
/>
<EditText
android:id="@+id/etLastName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/last_name"
android:inputType="textCapWords"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etFirstName" />
<TextView
android:id="@+id/dob"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:drawablePadding="10dp"
android:drawableEnd="@mipmap/mdate"
android:gravity="center_vertical"
android:padding="10dp"
android:hint="@string/dob"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toStartOf="@+id/genderSpinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etLastName" />
<Spinner
android:id="@+id/genderSpinner"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:background="@drawable/profile_background"
android:entries="@array/gender"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/dob"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/dob"
app:layout_constraintTop_toTopOf="@+id/dob"/>
<EditText
android:id="@+id/etMobileno"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/mobile_txt"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/genderSpinner" />
<EditText
android:id="@+id/etAddress"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/address"
android:inputType="textCapWords"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etMobileno" />
<EditText
android:id="@+id/etCity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/S_city"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etAddress" />
<EditText
android:id="@+id/etPincode"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="@drawable/profile_background"
android:padding="10dp"
android:hint="@string/pincode"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etCity" />
<TextView
android:id="@+id/tvMandatory"
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_marginTop="10dp"
android:text="@string/mandatory"
android:textColor="@color/white"
android:textSize="10sp"
android:gravity="right"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etPincode" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivProfile"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="10dp"
android:src="@drawable/prof_img"
app:civ_border_color="#000"
app:civ_border_width="0.5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvMandatory" />
<TextView
android:id="@+id/tvChoosePhoto"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:background="@drawable/prof_cam"
android:gravity="center|left"
android:paddingLeft="@dimen/plus_15dp"
android:text="CHOOSE YOUR PHOTO"
android:textColor="@color/black"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="@+id/ivProfile"
app:layout_constraintLeft_toRightOf="@+id/ivProfile"
app:layout_constraintTop_toTopOf="@+id/ivProfile" />
<TextView
android:id="@+id/tvClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:gravity="center|left"
android:text="@string/clear"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@+id/tvChoosePhoto"
app:layout_constraintLeft_toRightOf="@+id/tvChoosePhoto"
app:layout_constraintTop_toTopOf="@+id/tvChoosePhoto"
tools:ignore="MissingConstraints" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
<Button
android:id="@+id/btUpdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_update"
android:text="UPDATE"
android:layout_marginBottom="10dp"
android:textColor="@color/white"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
引用将在插入光标下绘制的drawable。
<EditText
......
android:textCursorDrawable="@null"
android:focusableInTouchMode="true"
答案 1 :(得分:0)
试试这个
MediaPlayer