【问题标题】:implementing list views android实现列表视图android
【发布时间】:2011-06-21 14:26:01
【问题描述】:

我需要在 android 中实现这个布局。视图必须有两个共享 30-70% 屏幕空间的列表视图。 右侧的列表必须是水平可滚动且垂直的...左侧的列表必须只能在垂直方向上滚动...并且当任一列表项(记录)必须位于同一行时列表向上/向下滚动。我尝试以这种方式实现相同的方法,它工作正常,但滚动时不够平滑......而且大多数时候屏幕变黑......

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical">
        <LinearLayout android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:orientation="horizontal">
        <ListView android:id="@+id\lV1" android:layout_width="100dp"
                android:layout_height="wrap_content" />
            <HorizontalScrollView android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <ListView android:id="@+id/lV2" android:layout_width="wrap_content"
                    android:layout_height="wrap_content"  />
            </HorizontalScrollView>
        </LinearLayout>
</LinearLayout>

请注意,整个布局需要显示在选项卡视图中。 我把布局改成这个了,还是没有好结果

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="fill_parent" android:fillViewport="true"
    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
    <RelativeLayout android:layout_width="match_parent"
        android:layout_height="fill_parent" >
        <ListView android:id="@+id/lV1" android:layout_width="100px"
            android:layout_height="wrap_content" android:background="@color/white"
            android:fadingEdge="vertical" android:cacheColorHint="#00000000"
            android:fastScrollEnabled="true" />
        <HorizontalScrollView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_toRightOf="@id/listView1">
            <ListView android:id="@+id/lV2" android:layout_width="wrap_content"
                android:fastScrollEnabled="true" android:layout_height="wrap_content"
                android:background="@color/white" android:cacheColorHint="#00000000"
                android:layout_toRightOf="@id/lV1" />
        </HorizontalScrollView>

    </RelativeLayout>
</ScrollView>

【问题讨论】:

  • 我不确定我们是否可以在 Horizo​​ntalScrollView 中实现 ListView。它会为您水平滚动吗?
  • @khotmanish..是的,它确实有效......但有点慢

标签: android listview android-layout


【解决方案1】:

android:cacheColorHint="#00000000" 添加到您的列表视图应该可以防止列表变黑

【讨论】:

  • @Sashi..thanks..它对黑屏很有用...关于如何使其平滑滚动的任何想法
  • 您是否在 Adapters getView 方法中重用视图?看看重用传入的 convertView 参数。在这里查看更多信息use convertview
猜你喜欢
  • 2014-08-17
  • 1970-01-01
  • 2012-04-13
  • 2016-05-26
  • 1970-01-01
  • 2010-12-15
  • 1970-01-01
  • 2019-01-17
  • 1970-01-01
相关资源
最近更新 更多