0

step1:

XML layout:

<?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>

step2:

CustomView lineView=new CustomView(activity)

RelativeLayout.addView(lineView)

This layout_content addView not work, but rootView_layout addView normal, doubt parent View NestedScrollView affected. but addView after not show ,why?

step3:

rootView_layout.requestLayout() // dont work

rootView_layout.invalidate() // dont work

rlayout_content.requestLayout() // dont work

rlayout_content.invalidate() //dont work

soso
  • 1
  • 2
  • please elaborate your question properly and in detail. – Ayush Kumar Jan 14 '19 at 07:59
  • I want dynamic addView to RelativeLayout (rlayout_content), Do not show after adding, because the parent layout is NestedScrollView , I hope that the new View will scroll with RecyclerView together. – soso Jan 15 '19 at 07:07

0 Answers0