How to make Diamond shape xml background for android view

0 votes

 I am using below code

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
            android:fromDegrees="45"
            android:pivotX="-40%"
            android:pivotY="87%"
            android:toDegrees="45">
            <shape android:shape="rectangle">
                <stroke
                    android:width="10dp"
                    android:color="@color/colorAccent" />
                <solid android:color="@color/colorAccent" />
            </shape>
        </rotate>
    </item>
</layer-list>

but result is triangle 

Jun 1, 2022 in Others by polo
• 1,480 points
1,715 views

1 answer to this question.

0 votes

you can do this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="50dp"
        android:left="50dp"
        android:right="50dp"
        android:top="50dp">
        <rotate android:fromDegrees="45">
            <shape>
                <size
                    android:width="200dp"
                    android:height="200dp"/>
                <stroke
                    android:width="10dp"
                    android:color="#358165"/>
                <solid android:color="#69BE9E"/>
            </shape>
        </rotate>
    </item>
</layer-list>
answered Jun 1, 2022 by nisha
• 2,210 points

Related Questions In Others

0 votes
0 answers

How to make grid view scroll horizontally not vertically in android?

I have a dynamic Grid View. If ...READ MORE

May 21, 2022 in Others by Kichu
• 19,050 points
627 views
0 votes
1 answer
0 votes
1 answer

How to make android phone flashlight blink?

This might be too fast to blink:- String[] ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
1,453 views
0 votes
1 answer

How to apply zoom animation for each element of a list in angular?

Hey @Sid, do check if this link ...READ MORE

answered Jul 30, 2019 in Others by Vardhan
• 13,190 points
1,193 views
0 votes
1 answer

Manifest Merger failed with multiple errors in Android Studio

Open application manifest (AndroidManifest.xml)  > Merged Manifest. ...READ MORE

answered Apr 29, 2022 in Other DevOps Questions by narikkadan
• 63,420 points
1,304 views
0 votes
0 answers

How to define a circle shape in an Android XML drawable file?

I'm having some trouble locating the Android ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
1,657 views
0 votes
0 answers

can we make multi color gradient in xml for android background?

There are only 3 options available for ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
512 views
0 votes
0 answers

How to put a <vector> in a <shape> in Android?

I'm trying to make customizable icons in ...READ MORE

Dec 8, 2022 in Android by Edureka
• 12,690 points
546 views
0 votes
1 answer

How to prepare an APK for the Amazon Android App Store

you should use zipalign during every build, ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
322 views
0 votes
1 answer

How to make a countdown timer in Android?

package com.example.countdowntimer; import java.util.concurrent.TimeUnit; import android.app.Activity; import android.os.Bundle; import android.os.CountDownTimer; import android.widget.TextView; public ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,858 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP