Android:从文本视图中删除最大宽度属性

Zac*_*ske 3 android textview

所以我有一个文本视图,其上设置了 maxWidth 属性。

<com.workday.workdroidapp.sharedwidgets.KingfisherTextView
    android:id="@+id/contact_item_title"
    android:layout_width="wrap_content"
    android:maxWidth="@dimen/contact_cell_title_max_width"
    android:layout_height="wrap_content"
    style="@style/Title.Dark"
    android:maxLines="1"
    android:ellipsize="end"
    tools:text="Title" />
Run Code Online (Sandbox Code Playgroud)

假设我想以编程方式删除 maxWidth,因为通常会让我想要约束它的文本视图是空的。我怎样才能做到这一点?我似乎可以访问的唯一方法是 setMaxWidth,没有特殊值来删除该标志。

Mat*_*son 5

只需致电myTextView.setMaxWidth(Integer.MAX_VALUE). 这实际上就是 TextView 内部所做的事情:

私有 int mMaxWidth = Integer.MAX_VALUE;

https://android.googlesource.com/platform/frameworks/base/+/jb-mr0-release/core/java/android/widget/TextView.java