【问题标题】:Dynamically set imageview height and width in a listview在列表视图中动态设置图像视图的高度和宽度
【发布时间】:2014-04-26 04:46:41
【问题描述】:

我需要能够获取设备屏幕宽度并将其设置为图像视图的高度和宽度。图像视图位于列表视图中。我目前在我用于列表视图的 baseadapter 类中为图像视图设置布局参数。但这会减慢列表视图的滚动速度。当我删除以下代码时,列表视图滚动正常。有什么帮助吗?

RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(width, width);
holder.myimageview.setlayoutParams(rlp);

【问题讨论】:

    标签: listview android-imageview


    【解决方案1】:

    你试过这些滚动视图参数了吗?

    <ListView
        android:id="@+id/postlist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fastScrollEnabled="true"
        android:persistentDrawingCache="scrolling"
        android:scrollingCache="false"
        >
    </ListView>
    

    Android: fastScrollEnabled 和 Android: scrollingCache 改善了我的用户体验。

    还有看下面advice to improve your scroll speed

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      • 2014-06-21
      相关资源
      最近更新 更多