Issue
I want to set custom font size of hint of TextInputEditText
. I have an style which I want to apply to my all TextInputEditText
.
It is not applying on my TextInputEditText
. Can anyone help me where I am missing something ?
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Widget.Design.TextInputLayout" parent="AppTheme">
<item name="hintTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item>
</style>
<style name="AppTheme.TextFloatLabelAppearance" parent="TextAppearance.Design.Hint">
<item name="android:textSize">18sp</item>
</style>
</resources>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".login.AuthenticationActivity"
android:label="@string/login_screen_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
layout.xml
<android.support.design.widget.TextInputLayout
android:id="@+id/access_code_input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/guideline"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_participation_access_code"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
Solution
You can either directly apply app:hintTextAppearance
to TextInputLayout
:
<android.support.design.widget.TextInputLayout
...
app:hintTextAppearance="@style/AppTheme.TextFloatLabelAppearance"
...
>
Or change your activity's or application's theme in AndroidManifest.xml
:
android:theme="@style/Widget.Design.TextInputLayout"
Answered By - azizbekian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.