当前位置: 代码迷 >> Android >> 在android中滚动视图
  详细解决方案

在android中滚动视图

热度:102   发布时间:2023-08-04 12:02:02.0

首先抱歉我的英语不好,我创建了 XML 文件,如何滚动我的图像和网格视图,我的网格视图滚动得很好但是我的图像视图没有随着我的网格视图滚动,当我使用 MOTO g 和 nixes 时设备我的图像可以正常显示,但是当我尝试显示与 MOTO E 小屏幕设备相同的设备时,我的网格视图无法正常工作

主要活动

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

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

    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="120sp"
    android:src="@drawable/spr"

     android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:scaleType="centerCrop"
    />


<GridView
    android:id="@+id/gridview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
      android:layout_below="@+id/image"
      android:columnWidth="90dp"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
     android:layout_margin="10dp"

    android:numColumns="2" />


 <ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_centerInParent="true"
    android:visibility="gone"/>



 </RelativeLayout>>
 </ScrollView>

图片活动

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
    android:id="@+id/picture"
    android:layout_width="match_parent"
    android:layout_height="220sp"
    android:scaleType="centerCrop"

    />

在“dp”而不是“sp”中设置 ImageView 高度。

  相关解决方案