gpt4 book ai didi

Android ListView : scrolling resizes the items in a weird way

转载 作者:行者123 更新时间:2023-11-29 02:14:12 24 4
gpt4 key购买 nike

我对 ListView 及其项目有疑问。当向上/向下滚动 ListView 时,我注意到项目略微调整了大小(大约一个像素),在我的应用程序中它看起来像 ^。两个项目之间的分隔线应该是一个像素高(使用默认的 android 行为),但是当滚动时分隔线有时是 2 像素或 0 像素(不可见)。这很糟糕,因为看起来这两项构成了一个列表项。

在 ListView 中滚动时,有没有人解决这个奇怪的调整大小问题?

我的开发设备是固件版本为 2.1-update1 的 HTC Wildfire。模拟器设置为:Android 2.1-update1,皮肤 WVGA800 和 hw.lcd.density=240。

ListView 填充了以下项目布局,我使用 ListView 的默认设置:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="#F0F0F0">
<ImageView
android:id="@+id/test_icon"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:src="@drawable/icon"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scaleType="centerInside">
</ImageView>
<TextView
android:id="@+id/testTextView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/test_icon"
android:text="test"
android:textColor="#555555" />
</RelativeLayout>

谢谢!

最佳答案

尝试将 android:gravity 设置为 center|fill 在外部元素或两个内部元素上。这解决了我遇到的滚动时调整大小的问题。

关于Android ListView : scrolling resizes the items in a weird way,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5417654/

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