2017-06-14 9 views
1

In meiner App gibt es ein ImageButton auf WebView, aber wenn ich die Seite nach unten scrollen, bleibt es auf der Oberseite. Wie kann ich das beheben?Set Imagebutton on webview

<LinearLayout android:layout_height="match_parent" 
     android:layout_width="fill_parent" 
     android:orientation="vertical"> 

     <WebView 
      android:layout_height="wrap_content" 
      android:id="@+id/webView" 
      android:layout_width="fill_parent"> 

      <ImageButton 
       android:id="@+id/imageButton" 
       android:layout_width="88dp" 
       android:layout_height="88dp" 
       android:layout_x="292dp" 
       android:layout_y="450dp" 
       android:background="@drawable/downloadarrow" /> 
     </WebView>  
</LinearLayout> 

Antwort

0

Versuchen Sie, eine ConstraintLayout

zB mit:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.test.mytest.MainActivity" 
    tools:showIn="@layout/app_bar_main"> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" 
     tools:layout_editor_absoluteX="148dp" 
     app:layout_constraintBottom_toBottomOf="@+id/webView1" 
     android:layout_marginBottom="8dp" /> 

    <WebView 
     android:id="@+id/webView1" 
     android:layout_width="368dp" 
     android:layout_height="495dp" 
     android:layout_marginBottom="0dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     tools:layout_editor_absoluteX="8dp" /> 

</android.support.constraint.ConstraintLayout> 

dies ermöglicht die Taste in Position zu bleiben, während Sie die Webansicht scrollen

EDIT:

Haben Sie versucht, den Button nur aus dem Webview zu entfernen?

<LinearLayout android:layout_height="match_parent" 
    android:layout_width="fill_parent" 
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <ImageButton 
     android:id="@+id/imageButton" 
     android:layout_width="88dp" 
     android:layout_height="88dp" 
     android:layout_x="292dp" 
     android:layout_y="450dp" 
     android:background="@drawable/ic_menu_gallery" /> 

    <WebView 
     android:layout_height="wrap_content" 
     android:id="@+id/webView" 
     android:layout_width="fill_parent"> 

    </WebView> 
</LinearLayout> 

Wenn Sie Vollbild-Modus wollen einfach das Linearlayout auf eine relativelayout ändern:

<RelativeLayout android:layout_height="match_parent" 
    android:layout_width="fill_parent" 

    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <WebView 
     android:id="@+id/webview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <Button 
     android:id="@+id/btn1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</RelativeLayout> 
+0

Aber es zeigt nicht die Taste – th3gr3yman

+0

@ th3gr3yman versuchen, die Position tauschen, legen Sie die Taste nach der Webansicht – Tony

+0

es ist die gleiche Sache – th3gr3yman