шаг 1:
Макет XML:
<?xml version = "1.0" encoding = "UTF-8"?>
<RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:tools = "http://schemas.android.com/tools"
android:id = "@+id/rootView_layout"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical">
<android.support.v4.widget.NestedScrollView
android:id = "@+id/nestedScrollView"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:fillViewport = "true"
android:overScrollMode = "never">
<RelativeLayout
android:id = "@+id/rlayout_content"
android:layout_width = "match_parent"
android:layout_height = "wrap_content">
<android.support.v7.widget.RecyclerView
android:id = "@+id/left_id"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginLeft = "@dimen/px_36"
android:layout_toLeftOf = "@+id/temp" />
<Space
android:id = "@+id/temp"
android:layout_width = "@dimen/px_150"
android:layout_height = "wrap_content"
android:layout_centerInParent = "true" />
<android.support.v7.widget.RecyclerView
android:id = "@+id/right_id"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginRight = "@dimen/px_36"
android:layout_toRightOf = "@+id/temp" />
<TextView
android:id = "@+id/txtv_answer"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_below = "@+id/left_id"
android:layout_marginTop = "@dimen/px_16"
android:textSize = "@dimen/sp_24" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
шаг 2:
CustomView lineView = новый CustomView (действие)
RelativeLayout.addView (lineView)
Этот layout_contentaddView не работает, но rootView_layoutaddView нормальный, сомневаюсь, что родительский просмотр NestedScrollView затронут.
но addView после не показывает, почему?
шаг 3:
rootView_layout.requestLayout () // не работает
rootView_layout.invalidate () // не работает
rlayout_content.requestLayout () // не работает
rlayout_content.invalidate () // не работает
Мне нужен динамический addView для RelativeLayout (rlayout_content). Не показывать после добавления, потому что родительский макет - это NestedScrollView, я надеюсь, что новый View будет прокручиваться вместе с RecyclerView.




пожалуйста, подробно и подробно изложите свой вопрос.