Expiredmind
Expiredmind

Reputation: 808

Set drawable shape on every item properly with margins

I want to made the listView that will looks like this

enter image description here

I suppose i need to use Frame layout in every Item and set margins to fit the left shape half outside the single item, but I dont know how to adjust it properly

I already have drawable shape I only need to set it up like on the picuture

edit: Maybe I need to place the drawable shape In my custom rounded_item_that looks like that

 <shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <stroke
        android:width="1dp"
        android:color="@color/gray" />

    <solid android:color="@color/white" />

    <padding
        android:left="5dp"
        android:right="5dp"
        android:top="5dp"
        android:bottom="10dp"/>

    <corners android:radius="5dp" />
    </shape>

Upvotes: 0

Views: 544

Answers (2)

Anchal Singh
Anchal Singh

Reputation: 329

Try this. It works..

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.v7.widget.CardView
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="40dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="50dp"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="Item 1" />

    </android.support.v7.widget.CardView>

</android.support.v4.widget.NestedScrollView>

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/fingerprint"
    app:layout_anchor="@id/cv"
    app:layout_anchorGravity="left|center"
    android:layout_margin="16dp"
    android:clickable="true"/>

Upvotes: 0

Rajesh Gosemath
Rajesh Gosemath

Reputation: 1872

This might help you

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">

    <LinearLayout
        android:id="@+id/layout1"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:background="#f1c21e"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal" />

    <LinearLayout
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="#000000"
        android:layout_alignStart="@+id/layout1"
        android:layout_alignLeft="@+id/layout1"
        android:layout_centerVertical="true"
        android:layout_marginLeft="-25dp"/>

        <!--set margin to half the width of the layout-->

</RelativeLayout>

enter image description here

Upvotes: 1

Related Questions