Search code examples
androidandroid-edittextaccessibility

Android Increase touch target of edit text as per accessibility without affecting design


<EditText
  android:id="@+id/caregiverFirstName"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@drawable/shape_round_corner_edit_text"
  android:fontFamily="@font/rubik_regular"
  android:hint="@string/type_here"
  android:imeOptions="actionDone"
  android:inputType="text"
  android:maxLength="50"
  android:maxLines="1"
  android:paddingStart="16dp"
  android:paddingTop="12dp"
  android:paddingEnd="16dp"
  android:paddingBottom="12dp"
  android:textColor="@color/main_vital_text_color"
  android:textColorHint="@color/edit_hint_color"
  android:textSize="16sp" />

If I add 14dp padding to top and bottom then the editText is as per accessibility but it is affecting design and increasing height of editText which I don't want. Is there any alternate solution to increase touch target with affecting design?


Solution

  • Instead of adding padding, consider using

    android:minHeight="48dp" android:minWidth="48dp"