Adarsh Dhakad
Adarsh Dhakad

Reputation: 407

how to create 3D shape of layout or Or button in android

In android XML how can create 3d layout or 3d button shape please help me I have already created a 2d layoutthis is my 2d design I want to add 3D shape. android:elevation and android:translationZ is not working because the background is already black and I want to add something like this see this 3d shape

Upvotes: 0

Views: 752

Answers (2)

Afsaneh Fallahzadeh
Afsaneh Fallahzadeh

Reputation: 11

  • create xml file in drawable folder with Root Element "layer-list" and copy this code inside of "layer-list" tag :)
<item>
    <shape android:shape="rectangle">
        <corners android:radius="50dp"/>
        <stroke android:width="3dp"
            android:color="#FFFFFF"/>

        <gradient android:startColor="#0094a8"
            android:endColor="#0094a8"
            android:centerColor="#06BDD8"
          />
    </shape>
</item>

<item android:height="20dp"
    android:top="8dp"
    android:end="25dp"
    android:start="25dp">
    <shape android:shape="rectangle">
        <corners android:radius="50dp"/>
        <solid android:color="#20ffffff"/>
    </shape>
</item>

This code is very similar to your request

Upvotes: 1

Muhammad Farhan Arif
Muhammad Farhan Arif

Reputation: 174

 <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item>        
            <shape>
                <gradient
                    android:endColor="#0905FB"
                    android:startColor="#9796FD"
                    android:angle="270" />
                <stroke
                    android:width="3dp"
                    android:color="#65655B" />
                <corners
                    android:radius="3dp" />  
                <padding
                    android:left="10dp"
                    android:top="10dp"
                    android:right="10dp"
                    android:bottom="10dp" />
            </shape>
        </item>
   </selector>

This will give the gradient and shape You can change gradient angle, color and button radius as per your requirement. Keep button in cardview and give elevation for 3d like view.

Upvotes: 1

Related Questions