用于安卓外部链接网络视图的按钮



我在Android中创建了一个Web视图,其中有外部链接。如果我单击该链接,它会重定向到另一个带有带有按钮的固定标题的 Web 视图。这是我的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.app.MainActivity"
tools:showIn="@layout/activity_main">
<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/activity_main_webview"/>
<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/external_webview"
    android:layout_alignBottom="@+id/activity_main_webview"
    android:layout_alignRight="@+id/activity_main_webview">
</WebView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="1">
        <Button
            android:id="@+id/backtonews"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/button"
            android:textSize="48dp" >
        </Button>
        <Button
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/refresh"
            android:textSize="48dp"
            android:layout_alignParentRight="true"
            android:singleLine="false">
        </Button>
    </RelativeLayout>    
  </RelativeLayout>
 </RelativeLayout>

现在我的问题是

  • 我的按钮显示在两个不应该显示的 Web 视图上。

  • 我在第二个 Web 视图中的内容与底部重叠,并且没有分开。

编辑

请参考此图片

<?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"
tools:context="com.app.MainActivity"
tools:showIn="@layout/activity_main">
<WebView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_below="@+id/layout"
    android:id="@+id/activity_main_webview"/>
<WebView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:id="@+id/external_webview"
    android:layout_below="@+id/activity_main_webview"
    android:layout_alignRight="@+id/activity_main_webview">

<RelativeLayout
    android:id="@+id/layout" 
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <Button
        android:id="@+id/backtonews"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="click"
         >
    </Button>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="click2"
        android:singleLine="false">
    </Button>
 </RelativeLayout>

最新更新