Skip to content

Commit

Permalink
单行选择的布局添加最大高度的限制
Browse files Browse the repository at this point in the history
  • Loading branch information
luyousheng committed Mar 1, 2019
1 parent a136ce5 commit e7b1ae2
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

/**
* 竖直单选样式
*/
Expand All @@ -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);

Expand Down

0 comments on commit e7b1ae2

Please sign in to comment.