Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout like Cards in android

I want to make an android layout like Google Cards,i know there is an Open Source Libraries, however i want only the Layout and the gray hex background style. I could not find information about this, how i can make this possible? im Attaching new Google maps v7 Layout so you can get the idea. Google Maps Layout

like image 662
Javier Avatar asked Jul 24 '13 20:07

Javier


People also ask

What is card layout Android?

CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other.

What is the best layout for Android?

LinearLayout is perfect for displaying views in a single row or column. You can add layout_weights to the child views if you need to specify the space distribution. Use a RelativeLayout, or even better a ConstraintLayout, if you need to position views in relation to siblings views or parent views.

Which layout is used in Android?

Android Frame Layout: FrameLayout is a ViewGroup subclass, used to specify the position of View elements it contains on the top of each other to display only a single View inside the FrameLayout. Android Table Layout: TableLayout is a ViewGroup subclass, used to display the child View elements in rows and columns.


1 Answers

bg_card.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#CCC" />
        </shape>
    </item>
    <item android:bottom="2dp">
        <shape android:shape="rectangle">
            <solid android:color="#FFF" />
        </shape>
    </item>
</layer-list>

Or just set the background of the card to #FFF and add at the bottom:

<View
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="#CCC" />

NOTE:

For everyone who doesn't care about using a library, you should use a CardView from the Android support library.

Sample code.

like image 192
RockoDev Avatar answered Nov 09 '22 02:11

RockoDev