переключение на Theme.MaterialComponents из Theme.AppCompat показывает белые пустые метки и кнопки - PullRequest
2 голосов
/ 25 марта 2020

Я использовал Материал Дизайн 1.1.0.

Для вкладок с viewpager2 я обновил его до '1.2.0-alpha05' Версия библиотеки * Material работала нормально для одного модуля, но зависала для другого модуля, где я разработал свой пользовательский Материал разработан TextInputLayout. Я изменил тему с 'Theme.AppCompat.Light.NoActionBar' на Theme.MaterialComponents.Light.NoActionBar и исправил cra sh. После исправления cra sh и обновления темы он показывает мне белую плавающую метку, кнопки, индикаторы и т. Д. c Кто-нибудь, пожалуйста, подскажите мне, где я делаю неправильно .?

GITHUb Issue Ticket Link: https://github.com/material-components/material-components-android/issues/1207

TextInputLayout

Стиль. xml (Старый файл)

    <!-- your app branding color for the app bar -->
    <item name="colorPrimary">@color/white</item>

    <!-- darker variant for the status bar and contextual app bars -->
    <item name="colorPrimaryDark">@color/colorPrimary_New</item>

    <!-- theme UI controls like checkboxes and text fields also known as secondary color -->
    <item name="colorAccent">@color/a465661</item>
</style>

старый файл конфликтовал с материалом при использовании AppCompact с parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" после обновления до 1.2.0-alpha05 он был разрешен, но стиль фона не работает сейчас

Библиотека

materialVersion = '1.2.0-alpha05'

 "com.google.android.material:material:$materialVersion"

. XML (Дизайн)

  <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/textInputLayout"
        style="@style/contentInputLayoutStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/_8dp"
        android:paddingStart="5dp"
        android:paddingLeft="5dp"
        app:helperTextEnabled="true"
        android:layout_marginLeft="@dimen/_8dp"
        android:layout_marginEnd="@dimen/_8dp"
        android:layout_marginRight="@dimen/_8dp"
        app:errorEnabled="false"
        app:layout_constraintBottom_toTopOf="@+id/errorTextView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:hint="@string/EnterMobileNumber">


        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/textInputEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="phone"
            android:gravity="start"
            android:textDirection="anyRtl"
            tools:text="0335510023"
            android:background="@null"
            android:paddingEnd="@dimen/inputFieldPadding_36dp"
            android:paddingRight="@dimen/inputFieldPadding_36dp" />

    </com.google.android.material.textfield.TextInputLayout>

Стиль. xml

 <style name="AppTheme"  parent="Theme.MaterialComponents.Light.NoActionBar" >
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/white</item>
            <item name="colorPrimaryDark">@color/green</item>
            <item name="colorAccent">@color/a465661</item>
        </style>

 <style name="contentInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
        <item name="boxStrokeColor">@color/border_stroke_grey</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:textStyle">normal</item>
        <item name="errorTextAppearance">@style/error_label</item>
        <item name="counterOverflowTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item>
        <item name="android:actionOverflowButtonStyle">@style/AppTheme.TextFloatLabelAppearance
        </item>
        <item name="hintTextAppearance">@style/text_label</item>
    </style>

 <style name="text_label" parent="TextAppearance.Design.Hint">
        <item name="android:textSize">@dimen/title_heading_12sp</item>
        <item name="colorControlNormal">@color/black</item>
        <item name="colorControlActivated">@color/black</item>
        <item name="colorControlHighlight">@color/black</item>
    </style>

    <style name="text_label_green" parent="TextAppearance.Design.Hint">
        <item name="android:textSize">@dimen/title_heading_12sp</item>
        <item name="colorControlNormal">@color/green_field</item>
        <item name="android:background">@null</item>
        <item name="colorControlActivated">@color/green_field</item>
        <item name="colorControlHighlight">@color/green_field</item>
    </style>

    <style name="AppTheme.TextFloatLabelAppearance" parent="text_label">
        <!-- Floating label appearance here -->
        <item name="android:textColor">@color/label_title_black</item>
        <item name="android:textSize">@dimen/title_heading_12sp</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="colorControlNormal">@color/label_title_black</item>
        <item name="colorControlHighlight">@color/label_title_black</item>
        <item name="colorControlActivated">@color/label_title_black</item>

    </style>

  <style name="material_edit_text" parent="Widget.AppCompat.EditText">
        <item name="android:paddingStart">50dp</item>
        <item name="android:paddingLeft">50dp</item>
        <item name="android:background">@null</item>
        <item name="android:textSize">16sp</item>
    </style>

    <style name="error_label" parent="TextAppearance.Design.Hint">
        <item name="android:textSize">0sp</item>
        <item name="android:textColor">@color/red</item>
        <item name="android:visibility">gone</item>
    </style>

  <style name="BtnCustomStyle">
        <item name="android:background">@drawable/btn_confirm_selector</item>
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">15dp</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">46dp</item>
        <item name="android:layout_marginStart">10dp</item>
        <item name="android:layout_marginEnd">10dp</item>
        <item name="android:textAllCaps">false</item>
        <item name="android:foreground">android:attr/selectableItemBackground</item>
    </style>

Стиль (v27). xml (удаленный файл)

   <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/white</item>
        <item name="colorPrimaryDark">@color/colorPrimary_New</item>
        <item name="colorAccent">@color/a465661</item>
        <item name="android:windowLayoutInDisplayCutoutMode">never</item>
    </style>

Обновление

"Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"

этой строки вызывала cra sh при использовании appCompact Theme.

Читайте topi c на материал дизайна Обновление пользовательского интерфейса. В соответствии с этим документом я должен добавить несколько атрибутов, которые ниже!

    <!-- New MaterialComponents attributes. -->

    <item name="colorOnPrimary">@color/whitee</item>
    <item name="colorOnSecondary">@color/colorPrimary_New</item>
    <item name="colorOnSurface">@color/a465661</item>-->
    <item name="colorSurface">@color/a465661</item>-->
    <item name="colorOnBackground">#212121</item>-->
    <item name="android:colorBackground">@color/background</item>
    <item name="colorError">#F44336</item>-->
    <item name="colorOnError">#FFFFFF</item>

, но я попытался изменить цвет для TextInputLayout, он работает нормально, а для кнопки - нет. Кто-нибудь, пожалуйста, сообщите мне, как справиться с этим с новым дизайном материала .?

ImageSample

1 Ответ

0 голосов
/ 28 марта 2020

Измените основной цвет на белый на другой, который отличается от фона.

...