Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to give your layout a 3D style?

I was surfing the web to find a new style for the android layout and I find a pretty interesting one. Here is the Image.

enter image description here

I know more than basics about layout, but what I wanna is how can I give a 3d style look like in the above image? Especially that #7881 Code Box.

Here is Something that I have tried.

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:bottom="-25dp"
        android:top="-25dp"
        android:left="25dp"
        android:right="25dp">
        <rotate android:fromDegrees="20">
            <shape android:shape="rectangle">
                <size
                    android:width="50dp"
                    android:height="100dp"/>
                <solid android:color="#E30B3E"/>
            </shape>

        </rotate>
    </item>
</layer-list>

The output is this

enter image description here

Overall it gives the textview a 3d look but I want something like that in the image.

Any Suggestions?

like image 528
HARSH ASHRA Avatar asked Jul 05 '20 14:07

HARSH ASHRA


People also ask

What is the best layout in Android Studio?

Use FrameLayout, RelativeLayout or a custom layout instead. Those layouts will adapt to different screen sizes, whereas AbsoluteLayout will not. Definitely right. I recommend RelativeLayout since it keeps the view hierachy flat.

What is Android constraint layout?

A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread). As such, we are planning on enriching its API and capabilities over time.

How do I create a layout in Android Studio?

Use Android Studio's main menu 1 In the Project window, click the module in which you want to add a layout. 2 In the main menu, select File &gt; New &gt; XML &gt; Layout XML File. 3 In the dialog that appears, provide the file name, the root layout tag, and the source set in which the layout belongs. 4 Click Finish to create the layout.

What is a style in Android Studio?

A style resource defines the format and look for a UI. A style can be applied to an individual View (from within a layout file) or to an entire Activity or application (from within the manifest file). A style is defined in an XML resource that is separate from the XML that specifies the layout.

What are styles and themes in Android?

Android - Styles and Themes. A style resource defines the format and look for a UI. A style can be applied to an individual View (from within a layout file) or to an entire Activity or application (from within the manifest file).

What are the different types of layouts in Android?

These are the types of layouts and out of them we’ll learn about the two very important layouts: 1. Linear Layout We use this layout to place the elements in a linear manner. A Linear manner means one element per line. This layout creates various kinds of forms on Android. In this, arrangement of the elements is in a top to bottom manner. a.


1 Answers

Its pretty much simple just use android:rotationX property on the CardView like this

    <com.google.android.material.card.MaterialCardView
        ...
        android:rotationX="20"
        ...

android:rotationX="20"android:rotationX="10"

like image 164
Arpan Sarkar Avatar answered Sep 21 '22 05:09

Arpan Sarkar