Android中的Imageview和gridview
我正在尝试开发一个Android应用程序,我需要一个特殊的布局 我想实现一个由屏幕顶部的imageview和底部的gridview组成的活动 布局是静态的,无法更改 我怎么能实现呢 这是我的代码:Android中的Imageview和gridview,android,android-layout,gridview,Android,Android Layout,Gridview,我正在尝试开发一个Android应用程序,我需要一个特殊的布局 我想实现一个由屏幕顶部的imageview和底部的gridview组成的活动 布局是静态的,无法更改 我怎么能实现呢 这是我的代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema
<?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="info.MainActivity"
tools:showIn="@layout/activity_main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ovada"/>
</LinearLayout>
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:columnWidth="300dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="5dp"
android:gravity="center"
android:stretchMode="columnWidth" >
</GridView>
</RelativeLayout>
事实上,这段代码并不是我想要的
****编辑1****
好的,我有一个问题:
1) 我得到的是:
- 在屏幕顶部显示“徽标”
- Gridview上方的图像“徽标”
- 图像和徽标可滚动
当我向下滚动“页面”时,我希望滚动页面的所有内容,而不仅仅是网格视图…将此添加到线性布局中:
android:id="@+id/linear_id"
android:alignParentTop="true"
和GridView
android:layout_below="@id/linear_id
我还建议您放弃线性布局,因为我认为添加它没有任何用处。对于ListView和GridView,将布局高度设置为包裹内容通常不是一个好主意。“包装内容”的意思是让我和我的孩子一样大。对于listView和GridView来说,这很难理解。最好将高度设置为与父项匹配