Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在根布局中使用 match_parent 是无效 #73

Open
zouchuqu opened this issue Aug 15, 2020 · 2 comments
Open

在根布局中使用 match_parent 是无效 #73

zouchuqu opened this issue Aug 15, 2020 · 2 comments

Comments

@zouchuqu
Copy link

在根布局中使用 match_parent 无效,使用比重参数(android:layout_weight)也是无效的,导致部分UI很难做适配。

<TextView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />
@QianHong
Copy link

同问 兄弟解决了吗

@QianHong
Copy link

public View getView(LayoutInflater inflater) {
ConstraintLayout cl = (ConstraintLayout) inflater.inflate(R.layout.bookdetail_detail_item_review_guide_view, null, false);
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
layoutParams.width = ScreenUtils.getScreenWidth();
cl.setLayoutParams(layoutParams);
LinearLayout ll = new LinearLayout(inflater.getContext());
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
ll.setOrientation(LinearLayout.VERTICAL);
param.width = ScreenUtils.getScreenWidth();
ll.setLayoutParams(param);
ll.addView(cl);
return ll;
}

这样好像有点用处

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants