androidandroid-layoutandroid-linearlayoutandroid-layout-weightxml-layout

Suspicious size this will make the view invisible (in child layout)


I have a child LinearLayout inside a LinearLayout

the inner Layout is showing a message saying

Suspicious size this will make the view invisible

I have set the orientation of the layouts the parent layout is Vertical and the inner layout is Horizontal I also set the layout_height of the controls inside it to 0dp and set the weight

I don't know why?

here is my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <CheckBox
        android:id="@+id/filter_ShowOnlyAvailableItems_Chk"
        android:layout_width="match_parent"
        android:text="@string/Search_ShowOnlyAvailableItems"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>

    <CheckBox
        android:id="@+id/filter_Color_Chk"
        android:layout_width="match_parent"
        android:text="@string/Search_FilterColor"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.86">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/filter_colors_recyclerview"
            android:layout_width="match_parent"
            android:background="@color/red"
            android:layout_height="wrap_content">
        </android.support.v7.widget.RecyclerView>
    </ScrollView>

    <LinearLayout
        android:padding="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8"/>


        <Button
            android:id="@+id/filter_ok_btn"
            android:text="@string/Filter_Ok"
            android:layout_width="0dp"
            android:textColor="@android:color/black"
            android:layout_weight="0.50"
            android:layout_margin="5dp"
            android:textAlignment="center"
            android:background="@drawable/buttonrounded"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/filter_cancel_btn"
            android:text="@string/Filter_Cancel"
            android:layout_width="0dp"
            android:layout_margin="5dp"
            android:textColor="@android:color/black"
            android:layout_weight="0.50"
            android:textAlignment="center"
            android:background="@drawable/buttonrounded"
            android:layout_height="wrap_content" />

    </LinearLayout>
</LinearLayout>

Solution

  • You have closed your linearlayout here.

     <LinearLayout
        android:padding="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8"/>
    

    Change this to

     <LinearLayout
        android:padding="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8">