gpt4 book ai didi

android - 如何使用 ListView 制作全屏垂直 ScrollView

转载 作者:搜寻专家 更新时间:2023-11-01 09:06:16 25 4
gpt4 key购买 nike

My screen image

我想让这个页面处于垂直 ScrollView 模式,但是你可以在下面看到一个 ListView ,我有来自网络服务的 ListView 项目

主要问题:

我的屏幕在滚动,但 ListView 项目不可滚动,我只能从网络服务中找到第一个结果

我在 xml 中使用了 fill_parent 属性,listview 项目仍然显示在小窗口中。任何人请告诉我如何创建这种类型的屏幕我已经在网上搜索过但没有得到任何正确的想法..谢谢

这是我的Xml文件

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/main_back_ground" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="50dp" >

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/header_mf" />

<ImageButton
android:id="@+id/imageButton"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_gravity="right|center"
android:layout_marginRight="15dp"
android:background="@drawable/cg_report_btn" />

<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_gravity="top"
android:layout_marginTop="50dp"
android:src="@drawable/header_yellow_line" />
</FrameLayout>

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_gravity="top"
android:src="@drawable/header_yellow_line" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="55dp"
android:orientation="vertical" >

<TextView
android:id="@+id/backkground_img_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:gravity="center_vertical"
android:text="Violin Genius takes the highschool championships"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="12dp" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/gallery_assignment_name"
android:textSize="10dp" />
</LinearLayout>
</FrameLayout>

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="200dp" >

<ImageView
android:id="@+id/imgViewGalleryBackgroundPic"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:background="@drawable/u15_normal"
android:scaleType="fitXY" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_gravity="bottom"
android:background="@drawable/app_feed"
android:orientation="horizontal" >

<ImageView
android:id="@+id/imgViewDetailTumbNail"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="@drawable/u17_normal_small" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Vote ."
android:textSize="12dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Comment ."
android:textSize="12dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Share"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@+id/gallery_detail_person_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="3dp"
android:text="@string/gallery_person_name"
android:textSize="8dp" />

<TextView
android:id="@+id/gallery_detail_views"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textSize="8dp" />

<ImageView
android:id="@+id/imageButton"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@drawable/view_icon" />

<TextView
android:id="@+id/gallery_detail_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:textSize="8dp" />

<ImageView
android:id="@+id/imageButton"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@drawable/comment_icon" />

<TextView
android:id="@+id/gallery_detail_favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="8dp" />

<ImageView
android:id="@+id/imageButton"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@drawable/heart_icon" />

<TextView
android:id="@+id/gallery_detail_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="8dp" />

<ImageButton
android:id="@+id/imageButton"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:background="@drawable/pin" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@drawable/divider_line" />
</FrameLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ScrollView
android:layout_width="fill_parent"
android:layout_height="70dp"
android:fillViewport="true" >

<TextView
android:id="@+id/gallery_image_detail"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_marginLeft="10dp"
android:padding="5dp"
android:singleLine="false"
android:text="@string/gallery_assignment_detail"
android:textSize="8dp" >
</TextView>
</ScrollView>
</RelativeLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:orientation="vertical" >

<com.google.android.maps.MapView
android:id="@+id/mapViewGallery"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:apiKey="0X_Jyk3FLOVfS4dJSGin89ME-m3u3QBwVFkXpvQ"
android:clickable="true"
android:enabled="true" >
</com.google.android.maps.MapView>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<!-- <ListView -->
<!-- android:id="@+id/listViewGalleryDetail" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:cacheColorHint="#00000000" -->
<!-- android:padding="5dp" > -->
<!-- </ListView> -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>


</ScrollView>

最佳答案

我已经通过使用 listview.addHeaderView(view); 解决了我的问题,通过使用这个属性,我在我的 ListView 之上添加了我的第二个 View ,它的工作就像魅力一样。

我们必须确保的一件事是,我们必须在调用 ListView 的 setAdapter() 之前调用此方法。

关于android - 如何使用 ListView 制作全屏垂直 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11684502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com