Добавить подвид в RelativeLayout - PullRequest
0 голосов
/ 14 января 2019

step1:

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>

step2:

CustomView lineView = новый CustomView (действие)

RelativeLayout.addView (lineView)

Это layout_content addView не работает, но rootView_layout addView нормальное, сомнительное родительское представление NestedScrollView затронуто. но addView после не показывают, почему?

step3:

rootView_layout.requestLayout () // не работает

rootView_layout.invalidate () // не работает

rlayout_content.requestLayout () // не работает

rlayout_content.invalidate () // не работает

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...