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 in Others by polo
• 1,500 points
145 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 by nisha
• 2,180 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 in Others by Kichu
• 19,040 points
67 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 in Others by nisha
• 2,180 points
38 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,200 points
512 views
0 votes
0 answers

Manifest Merger failed with multiple errors in Android Studio

 I was experimenting with Intent and I encountered with ...READ MORE

Apr 28 in Other DevOps Questions by Kichu
• 19,040 points
77 views
0 votes
1 answer

Is support XML Canon available in Jenkins?

Here is some information regarding your query ...READ MORE

answered Jun 1, 2018 in Jenkins by Damon Salvatore
• 5,980 points
287 views
0 votes
1 answer

How to read an XML file using XPath in Java?

Import the packages required to work with ...READ MORE

answered Jun 14, 2018 in Java by Akrati
• 3,190 points
2,896 views
0 votes
1 answer

How to pretty print XML from Java?

Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //initialize StreamResult ...READ MORE

answered Jul 4, 2018 in Java by Akrati
• 3,190 points
1,043 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 in Others by nisha
• 2,180 points
38 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 in Others by nisha
• 2,180 points
67 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP