屏幕顶部的横幅,web视图和底部的旗帜 [英] screen with top banner, webview and bottom banner

查看:127
本文介绍了屏幕顶部的横幅,web视图和底部的旗帜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个具有以下内容非常简单的Andr​​oid屏幕:顶部的横幅,web视图和底部的一面旗帜。出于某种原因,我不能这样做。我的XML如下:

I'm trying to create a very simple android screen with the following content: top banner, webview and bottom banner. for some reason, i can't do it. my xml look like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/FrameLayout02"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:fitsSystemWindows="true" android:isScrollContainer="false">


    <ImageView android:layout_width="wrap_content" android:layout_above="@+id/Web"
        android:layout_height="fill_parent" android:layout_gravity="top"
        android:src="@drawable/logo"></ImageView>


    <WebView android:layout_gravity="center" android:id="@+id/Web" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"></WebView>

    <ImageView android:layout_width="wrap_content" android:layout_below="@+id/Web"
        android:layout_height="fill_parent" android:layout_gravity="bottom"
        android:src="@drawable/logo"></ImageView>

</LinearLayout>

什么是错的?

谢谢,
丹尼尔

Thanks, Daniel

推荐答案

简短的回答全部是错误的。您code是一个烂摊子。

Short answer all is wrong. Your code is a mess.

长一点的回答。您正在试图有一个的ImageView 上方的WebView 并在底部另一个的ImageView 。我不完全知道什么是错误打破了它但这也并不重要。看看我的例子XML code。

Long answer. You are trying to have an ImageView above a WebView and at the bottom another ImageView. I'm not exactly sure what of the mistakes broke it but that's also not important. Take a look at my example XML code.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView android:id="@+id/topimage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:src="@drawable/icon"/>
    <ImageView android:id="@+id/bottomimage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:src="@drawable/icon"/>
    <WebView android:id="@+id/web"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/topimage"
        android:layout_above="@id/bottomimage"/>
</RelativeLayout>

现在我什么呢XML很简单。它采用了 RelativeLayout的作为容器,允许更灵活的子对齐。在的ImageView 名为 topimage 将调整其高度在其内容,并填写家长的宽度。它是顶部对齐到其父母。第二个的ImageView 是唯一的例外,它被固定到其父母底部相似。在的WebView 在两个的ImageView 秒之间对齐。它调整它的高度与ImageView`s高度。

Now what my XML does is simple. It uses a RelativeLayout as a container to allow a more flexible child alignment. The ImageView called topimage will adjust its height to its content and fill the parent in width. It is aligned to its parents top. The second ImageView is similar with the only exception that it is pinned to its parents bottom. The WebView is aligned in between both ImageViews. It adjust it's height to the 'ImageView`s heights.

尽量始终保持在你的XML某种结构,也Java的code,所以你还等可以扔了一脸不开始哭了起来。

Try to always keep some kind of structure in your XML and also Java code so you and also others can throw a look at it without starting to cry.

这篇关于屏幕顶部的横幅,web视图和底部的旗帜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆