ConstraintLayout 中 ScrollView 子布局不显示动态添加的控件

布局状态大概如下, NestedScrollView 也会出现

<ConstraintLayout >
...
<ScrollView
   android:id="@+id/id_sv_control"
>

<LinearLayout
   android:id="@+id/id_ll_control"
>

LinearLayout>

ScrollView>

ConstraintLayout >

解决方法:

for (int i = 0; i < count; i++) {
...
   id_ll_control.addView(itemView);
}
//加上这句
 id_sv_contect.post(new Runnable() {
            @Override
            public void run() {
                id_sv_contect.requestLayout();
            }
        });

你可能感兴趣的:(Android,解决方案)