4

How to get hint size of Enter Email Id(mentioned in this image) ?

image

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Ajith Ramsaran
  • 181
  • 3
  • 9
  • 2
    Possible 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 Answers2

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
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