android基于popwindow怎么调整位置和大小

看以前的效果:


4472062-48b5c223614e1d27.png
image.png

看现在的效果:


4472062-a7ea01955298b6ac.png
image.png

调整地方:
1、popwindow的showAtLocation方法

int marginLeft = ScreenUtil.dpToPx(mContext.getResources(), 20);
int marginTop = ScreenUtil.dpToPx(mContext.getResources(), 10);
this.showAtLocation(view, Gravity.CENTER_VERTICAL | Gravity.LEFT, marginLeft, marginTop);

2、由于表情嵌套了多个recycleview
第一层的recycleview(LinearLayoutManager + PagerSnapHelper),作用是:整页翻页
第一层的recycleview(GridLayoutManager),作用是:容纳表情

因此这里对第一层的recycleview固定宽度,不要wrap_content
如:

<cn.droidlover.xrecyclerview.XRecyclerView
        android:id="@+id/xrc_page_content"
        android:layout_width="@dimen/list_line_largeeer_240"
        android:layout_height="match_parent" />

3、在popwindow本身

this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);

猜你喜欢

转载自blog.csdn.net/weixin_33859665/article/details/87066660
今日推荐