From e7b1ae2e047df0e214d6265c1a38c5de4ad8b449 Mon Sep 17 00:00:00 2001 From: luyousheng Date: Fri, 1 Mar 2019 17:18:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E8=A1=8C=E9=80=89=E6=8B=A9=E7=9A=84?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=B7=BB=E5=8A=A0=E6=9C=80=E5=A4=A7=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../popupwindow/SingleSelectPopupWindow.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/filtertab/src/main/java/com/samluys/filtertab/popupwindow/SingleSelectPopupWindow.java b/filtertab/src/main/java/com/samluys/filtertab/popupwindow/SingleSelectPopupWindow.java index cb5ba83..40423ce 100644 --- a/filtertab/src/main/java/com/samluys/filtertab/popupwindow/SingleSelectPopupWindow.java +++ b/filtertab/src/main/java/com/samluys/filtertab/popupwindow/SingleSelectPopupWindow.java @@ -1,6 +1,7 @@ package com.samluys.filtertab.popupwindow; import android.content.Context; +import android.graphics.Rect; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -13,9 +14,12 @@ import com.samluys.filtertab.base.BaseFilterBean; import com.samluys.filtertab.base.BasePopupWindow; import com.samluys.filtertab.listener.OnFilterToViewListener; +import com.samluys.filtertab.util.Utils; import java.util.List; +import static android.view.View.MeasureSpec.AT_MOST; + /** * 竖直单选样式 */ @@ -33,7 +37,13 @@ public View initView() { View rootView = LayoutInflater.from(getContext()).inflate(R.layout.popup_single_select, null,false); rv_content = rootView.findViewById(R.id.rv_content); mAdapter = new PopupSingleAdapter(getContext(), getData()); - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); + final int maxHeight = Utils.dp2px(getContext(), 273); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()){ + @Override + public void setMeasuredDimension(Rect childrenBounds, int wSpec, int hSpec) { + super.setMeasuredDimension(childrenBounds, wSpec, View.MeasureSpec.makeMeasureSpec(maxHeight, AT_MOST)); + } + }; rv_content.setLayoutManager(linearLayoutManager); rv_content.setAdapter(mAdapter);