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();
            }
        });

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