Android 将材质1.1.0的版本更改为1.3.0

Android 将材质1.1.0的版本更改为1.3.0,android,styles,material-components-android,android-textinputlayout,Android,Styles,Material Components Android,Android Textinputlayout,还有我的第二个问题: 我使用TextInputLayout: <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="wrap_content"

还有我的第二个问题: 我使用TextInputLayout:

<com.google.android.material.textfield.TextInputLayout              
  style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColorHint="@color/LightBlue"              
 android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"
                app:boxStrokeColor="@color/selector"
                app:boxStrokeWidth="3dp"
                app:startIconTint="@color/white">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/numberOfPlayer_txt"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:inputType="numberDecimal"
                    android:textColor="@color/gold" />

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

样式文件

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

        <item name="android:windowBackground">@color/Thistle</item>
                   <!-- use in get player information -->
       <item name="CustomTextStyle">@style/Widget.App. TextInputLayout. 
       OutlinedBox</item>
  </style>


    <style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" 
     parent="">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="boxCornerRadiusBottomEnd">20dp</item>
        <item name="boxCornerRadiusBottomStart">20dp</item>
        <item name="boxCornerRadiusTopEnd">20dp</item>
        <item name="boxCornerRadiusTopStart">20dp</item>
        <item name="android:hint">Number of player</item>
        <item name="hintTextColor">@color/card1</item>
        <item name="startIconDrawable">@drawable/ic_people</item>
    </style>

    <style name="Widget.App.TextInputLayout.OutlinedBox" 
    parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="boxStrokeColor">@color/player_information</item>
        <item name="boxCornerRadiusBottomEnd">15dp</item>
        <item name="boxCornerRadiusBottomStart">15dp</item>
        <item name="boxCornerRadiusTopEnd">15dp</item>
        <item name="boxCornerRadiusTopStart">15dp</item>
        <item name="android:textColorHint">@color/white</item>
        <item name="startIconDrawable">@drawable/player</item>
        <item name="startIconTint">@color/gold</item>
        <item name="elevation">5dp</item>
        <item name="boxStrokeWidth">2dp</item>
        <itemname="materialThemeOverlay">@style/ThemeOverlay.App. 
         TextInputEditText.OutlinedBox</item>
        <item name="hintTextColor">@color/AntiqueWhite</item>
        <!-- .... -->
    </style>

    <style name="ThemeOverlay.App.TextInputEditText.OutlinedBox"  
    
   parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
        <!-- to change the cursor color -->
        <item name="colorControlActivated">@color/white</item>
    </style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/DarkSeaGreen" 
    android:state_focused="true"/>
    <item android:color="@color/white"/>
    </selector>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@颜色/蓟
@style/Widget.App。文本输入布局。
大纲框
@颜色/原色
20dp
20dp
20dp
20dp
玩家数量
@颜色/卡片1
@可抽出式/集成电路人员
@颜色/播放器信息
15dp
15dp
15dp
15dp
@颜色/白色
@可拖动/播放器
@颜色/金色
5dp
2dp
@style/ThemeOverlay.App。
文本输入文本框
@颜色/古董白色
@颜色/白色
这是我的选择器文件

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

        <item name="android:windowBackground">@color/Thistle</item>
                   <!-- use in get player information -->
       <item name="CustomTextStyle">@style/Widget.App. TextInputLayout. 
       OutlinedBox</item>
  </style>


    <style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" 
     parent="">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="boxCornerRadiusBottomEnd">20dp</item>
        <item name="boxCornerRadiusBottomStart">20dp</item>
        <item name="boxCornerRadiusTopEnd">20dp</item>
        <item name="boxCornerRadiusTopStart">20dp</item>
        <item name="android:hint">Number of player</item>
        <item name="hintTextColor">@color/card1</item>
        <item name="startIconDrawable">@drawable/ic_people</item>
    </style>

    <style name="Widget.App.TextInputLayout.OutlinedBox" 
    parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="boxStrokeColor">@color/player_information</item>
        <item name="boxCornerRadiusBottomEnd">15dp</item>
        <item name="boxCornerRadiusBottomStart">15dp</item>
        <item name="boxCornerRadiusTopEnd">15dp</item>
        <item name="boxCornerRadiusTopStart">15dp</item>
        <item name="android:textColorHint">@color/white</item>
        <item name="startIconDrawable">@drawable/player</item>
        <item name="startIconTint">@color/gold</item>
        <item name="elevation">5dp</item>
        <item name="boxStrokeWidth">2dp</item>
        <itemname="materialThemeOverlay">@style/ThemeOverlay.App. 
         TextInputEditText.OutlinedBox</item>
        <item name="hintTextColor">@color/AntiqueWhite</item>
        <!-- .... -->
    </style>

    <style name="ThemeOverlay.App.TextInputEditText.OutlinedBox"  
    
   parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
        <!-- to change the cursor color -->
        <item name="colorControlActivated">@color/white</item>
    </style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/DarkSeaGreen" 
    android:state_focused="true"/>
    <item android:color="@color/white"/>
    </selector>

和属性

 <resources>
   <attr name="customTextInputStyle" format="reference" />
   <attr name="CustomTextStyle" formet ="reference"/>
   </resources>

我以前创造的是扭曲的。它变得比以前更宽了。我找不到更改的原因。正如您在图片中看到的,文本输入布局非常宽,hinttext的背面看起来仍然是黑色的


主要问题在主题概述中。您必须添加父级
ThemeOverlay.MaterialComponents.textinputtext.OutlinedBox

<style name="ThemeOverlay.App.TextInputEditText.OutlinedBox" parent="@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
    <item name="colorPrimary">@color/...</item>
</style>
  • 最后,提示使用的颜色:
@color/red600深色
@颜色/青绿色700

最终布局:

   <com.google.android.material.textfield.TextInputLayout              
      style="@style/Widget.App.TextInputLayout.OutlinedBox"
            android:minWidth="150dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:startIconTint="@color/white">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/numberOfPlayer_txt"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:inputType="numberDecimal"
                    android:textColor="@color/gold" />

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

与:


@颜色/文本\输入\笔划\选择器
15dp
15dp
15dp
15dp
@可拉伸/集成电路。。。
@颜色/。。。
5dp
2dp
@style/ThemeOverlay.App.textInputItemText.OutlineBox
@颜色/。。。。
@颜色/。。。。
@颜色/。。。。

主要问题在主题概述中。您必须添加父级
ThemeOverlay.MaterialComponents.textinputtext.OutlinedBox

<style name="ThemeOverlay.App.TextInputEditText.OutlinedBox" parent="@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
    <item name="colorPrimary">@color/...</item>
</style>
  • 最后,提示使用的颜色:
@color/red600深色
@颜色/青绿色700

最终布局:

   <com.google.android.material.textfield.TextInputLayout              
      style="@style/Widget.App.TextInputLayout.OutlinedBox"
            android:minWidth="150dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:startIconTint="@color/white">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/numberOfPlayer_txt"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:inputType="numberDecimal"
                    android:textColor="@color/gold" />

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

与:


@颜色/文本\输入\笔划\选择器
15dp
15dp
15dp
15dp
@可拉伸/集成电路。。。
@颜色/。。。
5dp
2dp
@style/ThemeOverlay.App.textInputItemText.OutlineBox
@颜色/。。。。
@颜色/。。。。
@颜色/。。。。

我在问题中添加了图片我只需要做
我说得对吗?@Neo是的。在xml布局中删除android:theme=“@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined”
。你不需要它,它是错误的。请注意
wrapContent
,因为有一个大的圆角半径,字段可能会更高。为什么我需要将
@style/ThemeOverlay.MaterialComponents.textInputItemText.OutlineBox
添加到
@color/?非常感谢:)我在问题中添加了图片,我只需要做
对吗?@Neo是的。在xml布局中删除android:theme=“@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined”
。你不需要它,它是错误的。请注意
wrapContent
,因为有一个大的圆角半径,字段可能会更高。为什么我需要将
@style/ThemeOverlay.MaterialComponents.textInputItemText.OutlineBox
添加到
@color/?非常感谢:)