微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在TextInputLayout上增加counterView的marginTop?

如何解决如何在TextInputLayout上增加counterView的marginTop?

我的主题

 <style name="AppTheme" parent="@style/Theme.MaterialComponents.NoActionBar.Bridge">
    ...
    <item name="textInputStyle">@style/AppTextInputLayoutStyle</item>
    ...
 </style>

AppTextInputLayoutStyle:

<style name="AppTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
    <item name="passwordToggleDrawable">@drawable/password_drawable_selector</item><!-- icon Toggle at password field-->
    <item name="passwordToggleTint">@color/lightBlueGrey</item>

    <item name="android:textColorHint">@color/lightBlueGrey</item><!--text color of hint at TextInputEditText-->
    <item name="hintTextAppearance">@style/AppHintTextAppearance</item><!--text size of hint at focused TextInputLayout-->

    <item name="counterTextColor">@color/colorGrey</item><!--text color of counter-->
    <item name="counterTextAppearance">@style/AppCounterTextTextAppearance</item><!--text size and font of counter-->

    <item name="helperTextTextColor">@color/darkBlueGrey</item><!--text color of helper-->
    <item name="helperTextTextAppearance">@style/AppHelperTextTextAppearance</item><!--text size and font of helper-->

    <item name="materialThemeOverlay">@style/AppThemeOverlay</item>
    <item name="BoxCollapsedPaddingTop">0dp</item>
    <item name="BoxBackgroundMode">filled</item>
    <item name="BoxBackgroundColor">@android:color/transparent</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="errorIconDrawable">@null</item>
</style>

<style name="AppThemeOverlay" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox">
    <item name="colorPrimary">@color/colorAccent</item><!--text color at hintText of focused TextInputLayout-->
    <item name="colorError">@color/errorRed</item><!--error text color of TextInputLayout-->

    <!--Note: When setting a materialThemeOverlay on a custom TextInputLayout style,don’t forget to set editTextStyle to either a @style/Widget.MaterialComponents.TextInputEditText.*
    style or to a custom one that inherits from that.
    The TextInputLayout styles set materialThemeOverlay that overrides editTextStyle with the specific
    TextInputEditText style needed. Therefore,you don’t need to specify a style tag on the edit text.-->
    <item name="editTextStyle">@style/AppEditTextStyle</item>
</style>

<style name="AppEditTextStyle" parent="Widget.MaterialComponents.TextInputEditText.FilledBox">
    <item name="colorControlnormal">@color/appBluePrimary</item><!--underline color of TextInputEditText-->
    <item name="colorControlActivated">@color/colorAccent</item><!--underline color active of TextInputEditText-->
    <item name="android:background">@android:color/transparent</item>
    <item name="android:textColor">@color/appTextColorPrimary</item><!--text color of TextInputEditText-->

    <item name="android:paddingTop">24dp</item>
    <item name="android:paddingBottom">8dp</item>
    <item name="android:paddingStart">4dp</item>
    <item name="android:paddingEnd">4dp</item>
    <item name="android:paddingLeft">4dp</item>
    <item name="android:paddingRight">4dp</item>

    <item name="android:fontFamily">@font/montserrat_bold</item>
    <item name="fontFamily">@font/montserrat_bold</item>
</style>

<style name="AppHintTextAppearance">
    <item name="android:textSize">14sp</item>
</style>

<style name="AppHelperTextTextAppearance">
    <item name="android:textSize">12sp</item>
    <item name="fontFamily">@font/sourcesanspro_regular</item>
    <item name="android:fontFamily">@font/sourcesanspro_regular</item>
</style>

<style name="AppCounterTextTextAppearance">
    <item name="android:textSize">12sp</item>
    <item name="fontFamily">@font/sourcesanspro_regular</item>
    <item name="android:fontFamily">@font/sourcesanspro_regular</item>
</style>

结果视图如下所示:

enter image description here

如何增加counterView与EditText底线之间的距离?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。