在webview前面的带有adview,webview和搜索输入的XML

问题描述 投票:0回答:1

我的网页视图顶部有一个广告视图。我还在菜单栏中有一个搜索图标,当用户点击它时,我会向用户显示搜索字段。

问题是,搜索字段没有显示,我认为它是由webview覆盖的。

所以我想要这个:

enter image description here

我们hml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub">
    </com.google.android.gms.ads.AdView>

    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />

    <RelativeLayout
        android:id="@+id/layoutId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:visibility="gone" >

        <Button
            android:id="@+id/closeButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Close" />

        <Button
            android:id="@+id/nextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@+id/closeButton"
            android:text="Next" />

        <EditText
            android:id="@+id/findBox"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@+id/nextButton"
            android:hint="Enter search keyword here."
            android:singleLine="true" />
    </RelativeLayout>


</LinearLayout>

为什么我看不到搜索布局,如何按照我的意愿构建它?

android android-layout android-xml
1个回答
1
投票

首先,您的搜索输入的布局不可见(android:visibility=GONE)。

其次,它位于WebView下方而不是您想要的上方。

这应该可以解决您的问题:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">

    <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="ca-app-pub">

    </com.google.android.gms.ads.AdView>
    <RelativeLayout
            android:id="@+id/layoutId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="visible">

        <Button
                android:id="@+id/closeButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="Close"/>

        <Button
                android:id="@+id/nextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/closeButton"
                android:text="Next"/>

        <EditText
                android:id="@+id/findBox"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/nextButton"
                android:hint="Enter search keyword here."
                android:singleLine="true"/>
    </RelativeLayout>


    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/webView1"
             android:layout_width="fill_parent"
             android:layout_height="match_parent"/>

</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.