当视图中有文本时,如何使 `android:hint` 不占用 space?

How do I make `android:hint` not take up space when there is text inside the view?

目前,当您在某些 AppCompatEditTextAppCompatTextView 上设置 android:hint="..." 时,该提示还会为具有 android:height="wrap_content" 的对象设置隐式最小高度。

我将如何禁用此行为?

<android.support.v7.widget.AppCompatTextView
    android:paddingTop="12dp"
    android:paddingStart="16dp"
    android:paddingEnd="16dp"
    android:paddingBottom="12dp"

    android:hint="Apparently..."
    android:textColorHint="#BDBDBD"

    android:textSize="16sp"
    android:textColor="#000000"

    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

此问题的解决方法是像这样以编程方式将 textview/editexthint 设置为 ""

yourTextview.setHint("");

您可能仅在 yourTextview.getText().toString() 不是 "" 时才需要使用它,因此请使用

   if (!yourTextview.getText().toString().equals("")) {
        yourTextview.setHint("");
    }