How to get hint size of Enter Email Id(mentioned in this image) ?
Asked
Active
Viewed 1,397 times
4

Vikasdeep Singh
- 20,983
- 15
- 78
- 104

Ajith Ramsaran
- 181
- 3
- 9
-
2Possible duplicate of [Android EditText Hint Size](https://stackoverflow.com/questions/3139676/android-edittext-hint-size) – Sachin Rajput Jul 13 '18 at 06:07
-
@Thunder i am not asked about edit text hint size. i want text input layout edit text hint size when text input layout edit text onFocused. – Ajith Ramsaran Jul 13 '18 at 07:35
2 Answers
2
Text size of hint
is same as the text to be inputed in TextInputLayout
. To get textSize
in Java do like below:
XML:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="157dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="158dp">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/TextInputEditText"
android:layout_height="wrap_content"
android:hint="hint" />
</android.support.design.widget.TextInputLayout>
MainActivity.java:
final TextInputEditText textInputEditText = findViewById(R.id.TextInputEditText);
textInputEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
float size = textInputEditText.getTextSize();
Log.i("TEXT_SIZE", String.valueOf(size));
}
});
If you want to change textSize you can use textInputEditText.setTextSize();

Vikasdeep Singh
- 20,983
- 15
- 78
- 104
-
i am not asked about edit text hint size. i want text input layout edit text hint size when text input layout edit text onFocused- @VicJordan – Ajith Ramsaran Jul 13 '18 at 07:40
-
@AjithRamsaran check my updated answer. You can get textSize on focus of `TextInputEditText` – Vikasdeep Singh Jul 13 '18 at 07:49
-
-
-
@AjithRamsaran is this what you wanted? Please accept my answer if it helped you – Vikasdeep Singh Jul 13 '18 at 21:05
0
For example:
For get hint size you need to get a edittext
text size like this:
EditText mEmailId= findViewById(R.id.et_email);
mEmailId.getTextSize();
String.xml
<string name="edittext_hint"><font size="15">Hint set here</font></string>
then in your XML just write
<EditText
android:id="@+id/input_msg"
android:inputType="text"
android:hint="@string/edittext_hint" />
OR
Reduce the font size on the EditText
- that will reduce the size of the hint as well. i.e. android:textSize="15dp"

InsaneCat
- 2,115
- 5
- 21
- 40
-
1This is **wrong answer**. OP didn't ask to reduce the size, he just want to get size. Check my answer – Vikasdeep Singh Jul 13 '18 at 06:12
-
-
-
1@vicJordan nice way to get textsize , when focus changes it does the trick , upvote from me. – Sachin Rajput Jul 13 '18 at 08:09