Hide text selection handles on out of focus: Android -Webview

落爺英雄遲暮 提交于 2019-12-13 23:42:03

问题


I'm trying to hide the text selection handles when the user clicks somewhere else (a floating button) in webview, as shown in images the handles overlap with my linear layout. layout_meaning_selected_text is the element I hide and show after selection and clicking on the button.

any idea how to resolve this overlapping, and I want the text to be selected, it's just I want to make focus on that yellow part and after closing that, focus on the 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>


回答1:


 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   


来源:https://stackoverflow.com/questions/56033407/hide-text-selection-handles-on-out-of-focus-android-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!