Android EditText Hint
I don't know whether a direct way of doing this is available or not, but you surely there is a workaround via code: listen for onFocus event of EditText
, and as soon it gains focus, set the hint to be nothing with something like editText.setHint("")
:
This may not be exactly what you have to do, but it may be something like this-
myEditText.setOnFocusListener(new OnFocusListener(){
public void onFocus(){
myEditText.setHint("");
}
});
EditText with hint, where hint moves
if you mean this
it is TextInputLayout
Add the dependency for the design support library inside the build.gradle
(Module: app) file as shown below.
implementation 'com.google.android.material:material:<version>'
the latest version at this time is 1.2.0-alpha03
you can see latest version from mvnrepository
Then, you can use it like this in your xml layouts.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/myTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/my_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/YOUR_HINT"
android:singleLine="true"
android:textColor="@color/colorDarkestGray" />
</com.google.android.material.textfield.TextInputLayout>
Change EditText hint color when using TextInputLayout
Looks like the parent view had a style for a 3rd party library that was causing the EditText to be white.
android:theme="@style/com_mixpanel_android_SurveyActivityTheme"
Once I removed this everything worked fine.
Edit Text Hint is not visible in android studio design preview but is visible on emulator when app runs
This is usually the case with edittext.
Change the background of the edittext to white and it should display in the layout editor too.
If it doesn't, check the hint text colour.
Shifting edit text hints with android studio
You can use drawablePadding
property:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@android:drawable/star_big_on"
android:drawablePadding="10dp"
android:hint="Username"/>
Result:
Related Topics
Android: Changing Nfc Settings (On/Off) Programmatically
What Happens If a Android Service Is Started Multiple Times
Communicating with Serial Usb Device Over Android
Android: Broadcastreceiver Intent to Detect Camera Photo Taken
Asynctask, Must It Take Such a Performance Penalty Hit...
React-Native :Java.Lang.Unsatisfiedlinkerror: Couldn't Find Dso to Load: Libhermes.So
Android Device Is Not Connected to Usb for Debugging (Android Studio)
How to Get Chrome Browsing History/Bookmarks in Our Android App
In Espresso, How to Avoid Ambiguousviewmatcherexception When Multiple Views Match
How to Use Data Binding and Kotlin in Android Studio 3.0.0
Android:Load Svg File from Web and Show It on Image View
How to Test Boot_Completed Broadcast Receiver in Emulator
Android: Google Maps Location with Low Battery Usage
Status Bar Turns White and Does Not Show Content Behind It
Android Gcm (Push Notification): Device Doesn't Receive Notification If Application Is Stopped
Set Build Path in Eclipse for Ndk Program
How to Disable Dates Before Today Date in Datepickerdialog Android