有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    NonScrollListView上使用以下内容

    public class NonScrollListView extends ListView 
    {
    
     public NonScrollListView(Context context) 
     {
        super(context);
     }
     public NonScrollListView(Context context, AttributeSet attrs) 
     {
        super(context, attrs);
     }
     public NonScrollListView(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();
     }
    }
    
    <yourPackageName.NonScrollListView
                    android:layout_width="match_parent"
                    android:id="@+id/list_view"
                    android:scrollbarStyle="outsideOverlay"
                    android:layout_height="wrap_content"/>
    

    这会解决你的问题