Skip to content Skip to sidebar Skip to footer

Custom Background With Layer-list To Show Diagonal Lines?

I just want to create a custom background but I'm not getting how to do that with xml not with image. Here is the xml:

Digonal line

* *

2) Create the following XML drawable in android studio where "@drawable/diagonal_line" is the previous mentioned image:

<?xml version="1.0" encoding="utf-8"?><bitmapxmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/diagonal_line"android:tileMode="repeat"android:dither="true"
    ></bitmap>

what this bitmap drawable will do is take that single diagonal line and repeat it all over the selected view.

3) Now use that XML drawable as your view background, as an example, this is how I used it, where "@drawable/tiled_background" is the XML in step 2:

<Viewandroid:layout_width="match_parent"android:layout_height="45dp"android:background="@drawable/tiled_background"/>

and here is the result:

Tiled background

I hope this helps anyone. Happy Coding!

Solution 2:

Use

android:background="@drawable/yourcustombackground"

Define your custom background inside drawable (something like below)

<shapeandroid:shape="rectangle"><cornersandroid:radius="10dp"/><strokeandroid:width="1dp"android:color="#555555"/><solidandroid:color="#111111"/></shape>

Update: To display image at background

android:background="@drawable/ic_image"

ic_image is the desired image

Or you can use gradient also

Solution 3:

No. it is not possible in android to set diagonal line .You have to use image for it for the diagonal lines

Post a Comment for "Custom Background With Layer-list To Show Diagonal Lines?"