【发布时间】:2012-04-06 08:38:33
【问题描述】:
我创建了一个带有 RelativeLayout 的窗口,并在其中插入了两个控件;一个是GridView,一个是WebView。
我会将图像绑定到 gridview 以使用类似菜单,并且我将在 webview 中加载一个用于广告的 html 页面。
但我对这些控件有疑问。 例如,如果用户垂直滚动 gridview,它会消失在 webview 后面,因为我期待 webview 在用户滚动 gridview 时也会与 gridview 一起滑动。
所以我想知道,我可以将这些控件组合在一起以同时执行吗?
我的另一个方向问题,当我将我的设备转到横向模式时,webview 正在从屏幕上消失。
最后,如果我设置了 GridView 的 layout_height 属性 fill_parent,我看不到 WebView,所以我将它设置为 wrap_content。但是这次WebView没有底部对齐,它在GridView的后面对齐并且屏幕底部和webview之间有空间。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg480480">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
android:verticalSpacing="45dp"
android:horizontalSpacing="10dp"
android:columnWidth="150dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:layout_marginTop="30dp"
android:scrollbars="none"
android:layout_alignParentTop="true" />
<WebView
android:id="@+id/webView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:gravity="bottom"
android:layout_below="@id/gridview" />
</RelativeLayout>
这里是一些屏幕截图。
【问题讨论】:
-
尝试将您的 RelativeLayout 放入 ScrollView。