Kevin
09/22/2021, 9:57 AMLinearLayout
programatically based on EditText
focus. after doing some research, i found that you can easily changed it by using the drawable file method, i.e: android:state_focused="true"
.
while this is working when i apply it on the EditText
alone, there is a case where i need to put 2 icon images inside the LinearLayout
together with EditText
, i have tried to use some workaround of it by using FrameLayout
, while it workout quite well, i'm still trying whether if i able to do it while using LinearLayout
. so i wonder if anyone know how to do it on LinearLayout
?
below is my code for the structure of the LinearLayout
:
<LinearLayout
android:id="@+id/linear_textfield"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@drawable/textfield_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textfield_title">
<EditText
android:id="@+id/edittext_field"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="Placeholder text"
android:paddingHorizontal="16dp"
style="@style/body_text_medium"
android:textColor="@android:color/darker_gray"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:src="@drawable/icon_1"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_gravity="center_vertical|end"
android:src="@drawable/icon_2"
android:layout_marginEnd="16dp" />
</LinearLayout>