android - 起点和终点的画廊空间

标签 android gallery horizontal-scrolling

我遇到了以下问题,我制作了一个带有画廊的表格,画廊而不是包含图像包含我的一个类(class)中的项目,画廊每个项目中的所有内容都完美显示。我使用以下方法删除了图像之间的空间:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
        <Gallery android:id="@+id/galleryid"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:spacing="0dip"
                android:padding="0dip"
                android:layout_weight="1" />

画廊的项目:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="75dip" xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_horizontal" android:background="#ffffff"> 

    <TextView android:id="@+id/frame_number" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="-" android:textSize="12dip" android:textColor="#ffffff" android:background="#000000" android:gravity="center" />
    <LinearLayout android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" android:orientation="horizontal" android:gravity="center_horizontal">
                <TextView  android:id="@+id/frame_shot1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:textSize="18dip" android:textColor="#000000" />
                <TextView  android:id="@+id/frame_shot2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:textSize="18dip" android:textColor="#000000" />
    </LinearLayout> 
    <TextView android:id="@+id/frame_total" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="---" android:textSize="38dip" android:textColor="#000000"/>
</LinearLayout>

buuuuuuuuuuuuuuuuuut,我遇到了一个问题,画廊的开头和结尾有一些空白,没有任何项目。问题是我的画廊有很多项目,你实际上可以水平滚动,但我想摆脱那些空间所以画廊最左边的第一件事是第一个项目,当你滚动时是最后一个最右边是正确的项目。


编辑 08/16 项目中仍然存在同样的问题,在这里我留下一张图像,说明我正在尝试摆脱的是开头的黑色空间(也是结尾处的黑色空间)画廊在另一边)

enter image description here

最佳答案

左侧出现空白的原因很简单,因为第一个项目的左侧( View 居中)没有更多项目可显示。我认为同样的问题也出现在最后一项的右侧。

要正确解决这个问题,必须决定在没有更多项目时显示什么,但我会给出一些想法:

(1) 将图库项目的宽度增加到与图库相同的宽度将一次只显示一个项目,因此用户永远无法滚动到空白区域。

(2) 要在空白处显示纯色或图像,我会假设设置图库的 android:background 属性。

(3) 在适配器的开头和结尾创建一个缓冲区,分别由最后一个/第一个项目组成,当用户在缓冲区中滚动到足够远时,跳转到画廊另一端的匹配项目无限的“轮播”画廊。

关于android - 起点和终点的画廊空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6752310/

相关文章:

android - 如何录制Android耳机中播放的音频

android - 使用 Cordova 和 Eclipse 为 Android 创建一个 helloWorld 插件

Android获取颜色作为字符串值

css - 图片库媒体查询

css - 为什么我不能让 jquery ui sortable 有一个 "smooth"水平自动滚动?

ios - 水平滚动时如何防止 UITableView 内容被剪切?

android - 如何在 Android 中渲染数学方程式

android - 在 Android Honeycomb 中加速 Gallery 小部件的技巧

jquery - 单击图库中的链接会导致页面转到 'jump'?

javascript - 所以 DOM scrollIntoView 对齐顶部/底部,但是左/右呢?