隐藏文本选择手柄时无法聚焦:Android -Webview

时间:2019-05-08 04:08:33

标签: android xml layout webview textselection

当用户单击Web视图中的其他位置(浮动按钮)时,我试图隐藏文本选择手柄,如图像所示,这些手柄与我的线性布局重叠。 layout_meaning_selected_text是我在选择并单击按钮后隐藏并显示的元素。

关于如何解决这种重叠的任何想法,我希望选择文本,只是我要专注于该黄色部分,然后将其关闭,然后专注于所选文本。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">

    <com.myview.HorizontalWebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        tools:layout_editor_absoluteX="10dp"
        tools:layout_editor_absoluteY="10dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>

    <View
        android:layout_width="@dimen/afc_200dp"
        android:layout_height="@dimen/afc_200dp"
        android:layout_centerInParent="true"
        android:background="@drawable/watermark_logo_grey" />

    <include
        android:id="@+id/selection_panel"
        layout="@layout/custom_popup_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_margin="@dimen/afc_10dp"
        android:visibility="gone"
        tools:visibility="visible" />

    <include
        android:id="@+id/layout_editbookmark"
        layout="@layout/toast_with_icon"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="@dimen/afc_10dp"
        android:visibility="gone" />

    <include
        android:id="@+id/search_panel"
        layout="@layout/search_panel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_margin="@dimen/afc_10dp"
        android:visibility="gone" />

    <include layout="@layout/config_layout" />

    <include
        android:id="@+id/layout_meaning_selected_text"
        layout="@layout/layout_meaning_selected_text"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_alignParentBottom="true" />

</RelativeLayout>

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

 you have to take one EditText on your yellow page.
 Then you simply copy the selected text data from webView and paste it on the EditText...
 this will sort out your problem...
 otherwise if you dont wants to take EditText, then go for "Android - Clipboard" <https://developer.android.com/guide/topics/text/copy-paste> . 
 example 1: https://www.tutlane.com/tutorial/android/android-clipboard-with-examples
 example 2: https://www.tutorialspoint.com/android/android_clipboard.htm