Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw borders and separators on a View

I'm developing an App, and I need to draw borders and separators on a View, like the eBay app.

I think on a combination of shapes and view with 1dp. There is another easy way?

ebay App. Many thanks.

like image 505
Chronos Avatar asked Feb 02 '26 06:02

Chronos


1 Answers

Create a 9-patch image for the outside border. Use that as the background resource and it will give you the rounded corners with solid border. For dividers, you can create a simple view and have another background resource that's a simple image with the same color as the border in the 9-patch.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        android:orientation="vertical">

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedborder"
            android:orientation="vertical">

        <!-- Put Saved Searches display code here.  Probably LinearLayout/horizonal -->
        <TextView
                android:layout_width="fill_parent"
                android:layout_height="1dp"
                android:background="@drawable/simpleborder"
                android:layout_margin="3dp"/> <!-- Spacer! -->

        <!-- Put Favorite sellers display code here.  Probably LinearLayout/horizonal -->

    </LinearLayout>

</LinearLayout>
like image 188
Kevin Galligan Avatar answered Feb 04 '26 21:02

Kevin Galligan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!