Open zouchuqu opened 4 years ago
同问 兄弟解决了吗
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; }
这样好像有点用处
在根布局中使用 match_parent 无效,使用比重参数(android:layout_weight)也是无效的,导致部分UI很难做适配。