I need to add a RecyclerView
such that when there is a child element it should be visible or else it shouldn't be visible. So I have set the android:layout_height
attribute to wrap_content
thinking that it does the above work.
But when I does that the content above RecyclerView
in Android is visible and the rest of the layout space is occupying by the RecyclerView
.
So now can we do anything to make RecyclerView
s height to be dynamic?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="32dp"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:includeFontPadding="false"
android:text="@string/feedback_header"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<EditText
android:id="@+id/feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="@color/white"
android:gravity="start|top"
android:hint="@string/feedback_description"
android:maxLines="5"
android:minLines="5"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/darkGray"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/feedback_no_files"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/attach_file_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="@string/feedback_disclosure"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/darkGray"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"/>
</ScrollView>
</LinearLayout>