【问题标题】:Does Updating an Android Library cause Error in my Code?更新 Android 库会导致我的代码出错吗?
【发布时间】:2020-01-15 04:17:19
【问题描述】:

我正在使用 implementation group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha05' 库来渲染材料组件,但后来我将库更新为 implementation group: 'com.google.android.material', name: 'material', version: '1.2.0-alpha03' 一切不好的事情都发生了。我困惑了一个小时,问自己哪里做错了?

这是我必须经历的错误:

更新前:

This is the Image

更新后:

This is the Image

是我的代码有问题还是更新库的错。

这是 XML 中的代码:

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/DescriptionLayout"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:foregroundGravity="top"
                android:gravity="top"
                android:hint="@string/DescriptionHint"
                app:boxStrokeColor="@color/BoxColor"
                app:hintTextColor="@color/BoxColor">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/DescriptionEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top"
                    android:drawingCacheQuality="auto"
                    android:gravity="top"
                    android:inputType="textAutoCorrect|textMultiLine|text|textAutoComplete"
                    android:minLines="3"
                    android:singleLine="false"
                    android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>

更新到最新库后,TextInputLayout 中我的 EditText 的 android:gravity="top" 代码不起作用。

而且这不是唯一发生这种情况的地方。我应该更新图书馆吗?有人可以帮助我做出这个决定吗?如果不更新库,我的应用程序会无法正常工作吗?

很抱歉给您带来麻烦。

【问题讨论】:

  • 嗨!你解决了这个问题吗?
  • 我恢复到之前版本的材质库

标签: android xml layout android-library


【解决方案1】:

您能否尝试在样式中添加密集属性。 将此样式应用于您的 TextInputLayout。

style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"

Refer to this link

【讨论】:

  • 我无法在 29 Api 中获得该框,但该框在它之前的几乎所有 Api 中都存在。代码android:gravity="top" 也不起作用
  • 只有在我将库更新到 1.2.0-alpha03 后才会出现此问题
  • 好的,盒子在那里,但代码 android:gravity="top" 不起作用
  • 你试过用填充代替重力吗?
  • 我尝试使用填充,但填充在不同的设备上给了我不同的结果。我已将此情况报告给材料库开发人员。我希望他们在下一次更新中解决这个问题。
猜你喜欢
  • 2017-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-16
  • 2013-04-23
  • 1970-01-01
相关资源
最近更新 更多