while(ScreenUtil.px2dip(itemView.getWidth())<ScreenUtil.px2dip(mTagContainer.getWidth())+24){
ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) mTagContainer.getLayoutParams();
lp.width = ScreenUtil.dip2px(ScreenUtil.px2dip(mTagContainer.getWidth())-80);}
这里是80的原因是因为每一个小tag和他的marginleft数值加起来是80
<ConstraintLayout
<LinearLayout android:id="@+id/tag_container"
android:layout_width="380dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/first_line">
<ImageView
android:id="@+id/billions_logo"
android:layout_width="56dp"
android:layout_height="18dp"
android:layout_marginRight="4dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_tags"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
</ConstraintLayout>
<LinearLayout
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_marginLeft="8dp"
android:layout_width="72dp"
android:layout_height="18dp"
android:id="@+id/tv_tag_image"
/>
</LinearLayout>
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END