【发布时间】:2021-10-12 12:38:53
【问题描述】:
似乎在启用了文本选择的TextView 上,如果我长按空白区域,则会选择最近的单词并显示文本选择上下文菜单。是否可以更改此设置,并为 TextView 本身显示不同的上下文菜单,而不选择最近的单词?
我的意思是:长按某个单词会显示所选单词的上下文菜单(例如“复制/剪切/全选”),长按空白区域会显示 @ 的上下文菜单987654325@(类似于“重新加载页面”)。
PS:人们似乎并不理解“空白空间”。用黄线标记的区域就是我的意思。
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="@string/large_text"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@color/black"
android:textIsSelectable="true" />
</ScrollView>
</RelativeLayout>
【问题讨论】:
-
你所说的“空白区域”到底是什么意思,你能提供一些解释或图片吗?它是单词之间、行之间或文本周围的区域?
-
我想我明白你在找什么,你可以用
TextView+View来做,使TextView宽度wrap_content,所以如果用户长按空白区域(在本例中为查看)显示您的菜单 -
我只是指我们看到的视觉空白区域。从技术上讲,我可以在单词之间或两个段落之间的空行,但是我添加的屏幕截图顶部的“材料隐喻”和“是”之间的空格在视觉上是不同的。
标签: android textview android-widget