【问题标题】:TextView - Selected text pop up cut text belowTextView - 选中文本弹出剪切文本下方
【发布时间】:2022-08-05 01:01:40
【问题描述】:

我决定在我的 TextView 中添加选定的选项,但是当它被选中并弹出添加菜单时 - 它会将 TextView 剪切到下方。 选择前:

选择前: https://i.stack.imgur.com/9jbMN.png

选择后: https://i.stack.imgur.com/C3XWh.png

我该如何解决?

活动主:

<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
    xmlns:tools=\"http://schemas.android.com/tools\"
    android:layout_width=\"match_parent\"
    android:layout_height=\"match_parent\"
    android:background=\"@color/light_yellow\"
    android:gravity=\"center_horizontal\"
    android:orientation=\"vertical\"
    tools:context=\".MainActivity\">

    <TextView
        android:id=\"@+id/selected_date_field\"
        style=\"@style/MainTextStyle\"
        android:layout_width=\"wrap_content\"
        android:layout_height=\"wrap_content\"
        android:layout_marginTop=\"10dp\"
        android:text=\"@string/selected_date_field\" />

    <TextView
        android:id=\"@+id/selected_date\"
        style=\"@style/SecondTextStyle\"
        android:layout_width=\"wrap_content\"
        android:layout_height=\"wrap_content\"
        android:text=\"@string/selected_date\" />

    <TextView
        android:id=\"@+id/in_minutes_field\"
        style=\"@style/MainTextStyle\"
        android:layout_width=\"wrap_content\"
        android:layout_height=\"wrap_content\"
        android:layout_marginTop=\"10dp\"
        android:textIsSelectable=\"true\"
        android:textColorHighlight=\"@color/blue\"
        android:text=\"@string/in_minutes_field\" />

    <TextView
        android:id=\"@+id/in_minutes_till_date\"
        style=\"@style/SecondTextStyle\"
        android:layout_width=\"wrap_content\"
        android:layout_height=\"wrap_content\"
        android:text=\"@string/in_minutes_till_date\" />

</LinearLayout>```
  • 尝试 android:layout_width=\"wrap_content\"android:layout_width=\"match_parent\" 或使用填充

标签: android


【解决方案1】:

你可以试试 app:autoSizeTextType:uniform 那个 textView。 注意:如果您已经有“文本大小:15sp”之类的大小,请删除该行。

【讨论】:

    【解决方案2】:

    发现问题是由于在主题.xml我在&lt;item name="colorOnPrimary"&gt;@color/blue&lt;/item&gt; (背景)和&lt;item name="colorSecondary"&gt;@color/blue&lt;/item&gt;(处理程序的颜色)中有相同的颜色,因为它我看不到处理程序

    感谢大家!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      相关资源
      最近更新 更多