<EditText
android:id="#+id/textID"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_marginStart="208dp"
android:layout_marginLeft="208dp"
android:layout_marginTop="244dp"
android:background="#drawable/border_layout"
android:hint="Input ID."
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/textPassword"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_marginStart="208dp"
android:layout_marginLeft="208dp"
android:layout_marginTop="310dp"
android:background="#drawable/border_layout"
android:hint="Input PassWord"
android:inputType="textPassword"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
I created a simple EditText. When I touch the EditText to type, the EditText field hides the screen.
android:windowSoftInputMode="adjustResize"
This didn't solve the problem of the EditText field taking up the entire screen.
This app automatically switches to landscape mode when launched. Is this the problem?
This is a reference photo:
Is there any way to fix it?
Related
everyone. I have an AppCompatEditText field that is inside a TextInputLayout tag. Now I put a light shadow around the text box. Unfortunately, the whole thing is not displayed as I would like it to be, see picture. The lower part of the field does not appear. Do I have to set a distance, if so where?
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/suche"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:paddingBottom="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="288dp"
android:layout_marginEnd="20dp"
app:boxCornerRadiusBottomEnd="20dp"
app:boxCornerRadiusBottomStart="20dp"
app:boxCornerRadiusTopEnd="20dp"
app:boxCornerRadiusTopStart="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imgMain"
app:startIconDrawable="#drawable/ic_baseline_search_24">
<androidx.appcompat.widget.AppCompatEditText
android:elevation="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white_real"
android:background="#drawable/search_for"
android:hint="Suche..."
android:inputType="textEmailAddress">
</androidx.appcompat.widget.AppCompatEditText>
</com.google.android.material.textfield.TextInputLayout>
Set
android:layout_marginBottom="50dp"
instead of
android:layout_marginBottom="10dp"
I have made a login page and in it there are two fields, one for username and one for password, and
I can't seem to figure out a way to add padding to hints so the hints in the field look like this
and if I add the android:paddingTop="30dp"
it looks like this
this EditText is using a background source (field_bg) and also a user icon which changes its colors when the field is selected (custom_username_field).
here is the xml code for the username field.
<EditText
android:id="#+id/usernameField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints=""
android:background="#drawable/field_bg"
android:cursorVisible="false"
android:drawableStart="#drawable/custom_username_field"
android:drawablePadding="-30dp"
android:ems="10"
android:fontFamily="#font/staatliches"
android:hint="USERNAME"
android:includeFontPadding="true"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="#6E6E6E"
android:textSize="20sp"
android:paddingTop="30dp"
app:boxStrokeWidth="#null"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.507"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.421"
tools:ignore="TouchTargetSizeCheck" />
there is a poor solution to this problem:
android:textAlignment="center"
android:gravity="top"
tools:ignore="RtlCompat"
But in this case, the text that the user will enter will replace the hint and will be at the very top, which will not look nice. It would be possible to change the position of the text after the user has entered the text but for this you need to switch to code, not XML.
I also suspect that you plan to leave a prompt even after the user enters the text.
create hint in string.xml and then use in view
<EditText android:hint="#string/yourhint" />
You can try like this.
<EditText
android:id="#+id/usernameField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/round_10_background3"
android:drawableStart="#drawable/aa"
android:drawableTint="#color/white"
android:ems="10"
android:fontFamily="#font/caveat_semi_bold"
android:hint="USERNAME"
android:inputType="textPersonName"
android:padding="20dp"
android:textAlignment="center"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="20sp"
app:boxStrokeWidth="#null"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.507"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.421"
tools:ignore="TouchTargetSizeCheck" />
EditText icon not working correctly
In EditText I added end icon app:endIconDrawable="#mipmap/edit_icon" for all icon it turns into gray square
Updated code
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/profile_user_name_layout"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:hint="#string/user_name"
app:endIconMode="custom"
app:endIconTintMode="screen"
app:endIconDrawable="#mipmap/edit_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="#+id/profile_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
Actual icon
Output of Updated code
Setting app:endIconTintMode="screen" should fix the problem . Also for me icon is not visible without this attribute app:endIconMode="custom"
Let me try to explain the title.
I have a manufacturer TextView that is populated from MYSQL. When a manufacturer is selected it populates the Model TextView.
Now I want to add OTHER in each model, and when it is selected an EditText appears. Something like this:
-FORD
---Mustang
---Escape
---Other
-BMW
---X5
---Z4
---Other
Now whenever Other is selected, the EditText appears. If not, then it remains hidden.
The only way I got it working is by creating a field in mysql for each model. I am hoping there is a better approach.
Here is what I have done.
enter code here
<EditText
android:id="#+id/fordTextView"
android:layout_width="0dp"
android:layout_height="130px"
android:layout_marginStart="16dp"
android:visibility="gone"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:background="#drawable/custom_progress_bar_horizontal"
android:inputType="textPersonName"
android:paddingStart="#dimen/space_12"
android:hint="#string/item_entry__model"
android:paddingLeft="#dimen/space_12"
android:paddingTop="8dp"
android:paddingEnd="#dimen/space_12"
android:paddingRight="#dimen/space_12"
android:paddingBottom="8dp"
android:textAlignment="viewStart"
android:textColor="#color/text__primary"
android:textSize="14sp"
app:font='#{"normal"}'
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/plateNumTextView" />
<EditText
android:id="#+id/bmwTextView"
android:layout_width="0dp"
android:layout_height="130px"
android:layout_marginStart="16dp"
android:visibility="gone"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:background="#drawable/custom_progress_bar_horizontal"
android:inputType="textPersonName"
android:paddingStart="#dimen/space_12"
android:hint="#string/item_entry__model"
android:paddingLeft="#dimen/space_12"
android:paddingTop="8dp"
android:paddingEnd="#dimen/space_12"
android:paddingRight="#dimen/space_12"
android:paddingBottom="8dp"
android:textAlignment="viewStart"
android:textColor="#color/text__primary"
android:textSize="14sp"
app:font='#{"normal"}'
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fordTextView" />
Here is is the java
if (itemViewModel.holder.model_id.equals(Constants.MODEL_FORD_OTHER)){
binding.get().fordTextView.setVisibility(View.VISIBLE);
binding.get().bmwTextView.setVisibility(View.GONE);
}
if (!itemViewModel.holder.model_id.equals(Constants.MODEL_FORD_OTHER)){
binding.get().fordTextView.setVisibility(View.GONE);
binding.get().fordTextView.setText("");
}
if (itemViewModel.holder.model_id.equals(Constants.MODEL_BMW_OTHER)){
binding.get().bmwTextView.setVisibility(View.VISIBLE);
binding.get().fordTextView.setVisibility(View.GONE);
}
if (!itemViewModel.holder.model_id.equals(Constants.MODEL_BMW_OTHER)){
binding.get().bmwTextView.setVisibility(View.GONE);
binding.get().bmwTextView.setText("");
}
Is there a way of doing this by using only one EditText?
You can achieve this using single EditText, when ever click is registered for particular model Other button, set the model_id of that model as tag to the EditText. And while reading input from EditText, always check for tag to get the model_id
binding.get().modelTextView.setTag(""+itemViewModel.holder.model_id);
I am having an issue with EditText as when I entered lines more than it is being shown on the screen then EditText is hidden behind keyboard if I try to edit line which is below the visible area of EditText but If I edit any of those line which is in visible area it adjust the view for keyboard properly. I am not understanding what mistake I am doing?
I have used adjustPan as softInputMode.
Please have a look at this video to better understand what I want to say:
EditTextIssueVideo
EditText Code:
<EditText
android:id="#+id/notes_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:ems="10"
android:gravity="top|left"
android:hint="Notes"
android:inputType="textMultiLine"
android:padding="10dp"
android:maxLines="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/time_tp"
app:layout_constraintVertical_bias="0.202" />
It is probably because you have made your activity full screen. Try not making it full screen.
Check your AndroidManifest if you set
android:windowSoftInputMode="|adjustResize|adjustPan"
in any activity just remove it.