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

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

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

<LinearLayout
   android:id="@+id/id_ll_control"
>
<!-- 动态 addView-->
</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();
            }
        });

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章