【问题标题】:Disable ExpandableListView group header to move while scrolling禁用 ExpandableListView 组标题以在滚动时移动
【发布时间】:2014-08-09 10:07:07
【问题描述】:

当我展开组并滚动到子列表时,我在我的应用程序中使用 ExpandableListView;组标题也随着滚动而向上移动。请任何人帮助我禁用 组标题 向上移动只有子列表应该向上移动。

请帮我实现这个功能。

提前致谢

【问题讨论】:

  • 你得到这个工作了吗?请发布解决方案。
  • Here 是一个很好的例子。

标签: android expandablelistview


【解决方案1】:

我认为你不能用 ExpandableListView 做到这一点。

还有很多其他方法可以做到这一点

你应该检查一下,

StickyListHeadershttps://github.com/emilsjolander/StickyListHeaders

HeaderListViewhttps://github.com/applidium/HeaderListViewhttp://applidium.github.io/HeaderListView/

它可能会帮助你..

【讨论】:

    【解决方案2】:

    除了@Ajay 的回答,你还可以看到 Cabezas 在 ScrollView 中使用 ExpandableListView 的技巧here

    或者,您可以像这样创建自定义 NonScrollExpandableListView 类:

    public class NonScrollExpandableListView extends ExpandableListView {
    public NonScrollExpandableListView(Context context) {
        super(context);
    }
    
    public NonScrollExpandableListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public NonScrollExpandableListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
                Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
        ViewGroup.LayoutParams params = getLayoutParams();
        params.height = getMeasuredHeight();
    }
    

    }

    完整实现见https://stackoverflow.com/a/37605908/8771403

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多