Reputation: 407
In android XML how can create 3d layout or 3d button shape please help me I have already created a 2d layout 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
Upvotes: 0
Views: 752
Reputation: 11
<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
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