Redman Redman - 9 days ago 5
Android Question

Linear Layout negative margin , need one layout above another

i got this problem while giving negative margin See this pic

after giving negative margin i want that red part go below white part, to get shadow of categories on top of red box but as you see the redbox is coming on top

that white part is my relative layout and red part is my custom listview

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dim_10"
android:layout_marginRight="@dimen/dim_10"
android:background="@drawable/stripe_sort"
android:layout_marginTop="@dimen/dim_5"
android:layout_marginBottom="-15dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dim_10"
android:text="Categories"
android:textColor="#ff000000"
android:textSize="13sp"
tools:ignore="HardcodedText" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="true"
android:src="@drawable/sort_downarrow"
android:layout_centerVertical="true"

android:padding="@dimen/dim_15"
android:id="@+id/dropDown_categories"/>
</RelativeLayout>

<com.eminosoft.ebookread.util.ExpandableHeightListView
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/dim_12"
android:layout_marginRight="@dimen/dim_12"

android:background="#c03f2f"
android:id="@+id/ListView_Sort_categories"
android:visibility="visible"
android:paddingBottom="@dimen/dim_10"
android:divider="@null"
android:layout_gravity="center_horizontal"
/>


in this i added negative margin bottom to relative layout, i also tried to add negative margin top to my custom list view but still same result , parent of these both layouts is a linear layout

how can i make that listview go below relativelayout?

Answer
   <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <com.eminosoft.ebookread.util.ExpandableHeightListView
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:layout_marginLeft="@dimen/dim_12"
            android:layout_marginRight="@dimen/dim_12"
            android:layout_marginTop="-15dp"
            android:layout_below="@+id/partone"



            android:background="#c03f2f"
            android:id="@+id/ListView_Sort_categories"
            android:visibility="visible"
            android:paddingBottom="@dimen/dim_10"
            android:divider="@null"
            android:layout_gravity="center_horizontal"
            />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/dim_10"
            android:layout_marginRight="@dimen/dim_10"
            android:background="@drawable/stripe_sort"
            android:layout_marginTop="@dimen/dim_5"
            android:id="@+id/partone">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="@dimen/dim_10"
                android:text="Categories"
                android:textColor="#ff000000"
                android:textSize="13sp"
                tools:ignore="HardcodedText" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:checked="true"
                android:src="@drawable/sort_downarrow"
                android:layout_centerVertical="true"

                android:padding="@dimen/dim_15"
                android:id="@+id/dropDown_categories"/>
        </RelativeLayout>


    </RelativeLayout>

You can try this code,basically we put your layouts inside another relative layout