【问题标题】:Custom Layout on the WebViewWebView 上的自定义布局
【发布时间】:2011-04-19 07:40:28
【问题描述】:

我想在 WebView 上设置自定义布局。 .. 我已经完成了 LinearLayout 和 RelativeLayout 但我看不到 WebView 上的布局 怎么可能?请帮我。 . . 谢谢。

【问题讨论】:

    标签: android android-layout android-widget android-manifest


    【解决方案1】:

    保留一个父布局(说相对布局)并在那里设置您的布局,并根据您的需要在其中设置一个线性布局,并在其中添加 webview。 见以下代码

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 
        android:id="@+id/RelativeLayout01" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <ImageView 
            android:id="@+id/ImageView01" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:background="@drawable/main_title_bg"
            ></ImageView>
    
        <TextView 
            android:id="@+id/TitleText" 
            android:layout_height="wrap_content" 
            android:text="About us" 
            android:layout_width="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dip"
            android:textSize="18dip"
            android:textColor="#ffffff"
            ></TextView>
    
    <LinearLayout
        android:id="@+id/linearlayout01"
        android:layout_below="@id/ImageView01"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
    
        >
    
    <WebView  
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    
    />
    
    </LinearLayout>
    
    
    </RelativeLayout>
    

    希望这是你想要的......

    【讨论】:

    • 谢谢伙计,但我已经在 WebView 中设置了谷歌地图链接。当我查看它时,我看不到布局和默认 WebView。 .你能帮帮我吗???
    • 当然,只需将简单的 webview 替换为 Google MapView 并根据您的要求自定义布局即可。希望这能解决您的问题。
    • 是的,但问题是我在我的应用程序中使用 WebView 并解析源和目标地理点地址的现成 URl 以获取地图中的方向。现在如何在该视图上获取按钮或 Layouy ???有什么想法吗?
    • 您给出的代码未显示 WebView 上的标题部分和按钮。请检查您的代码。
    • 它会起作用的,我已经用过这个代码了。确保您使用任何名为 main_title_bg 的图像(可绘制)作为 ImageView 并将 WebView 保持在单独的布局中,就像我在上面的代码中所做的那样。和所有其他布局分开。希望你明白我的意思....?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多