Layout like Cards in android

泄露秘密 提交于 2019-12-03 06:57:38

问题


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.


回答1:


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.




回答2:


<item name="android:windowBackground">#ffe3e3e3</item> 

In your style.xml should make you happy ;-)

And for the layout, copying the card background should be enough isn't it?




回答3:


We can use the LayerList as above to achieve this (OR) by using the nine patch image get same effect, we need not create nine patch image separately for this puprpose android drawable have one.

if you are using eclipse: android:background="@drawable/abc_menu_dropdown_panel_holo_light"

copy paste the above line as your View backround.

or if you are using android studio copy paste the following line:

android:background="@android:drawable/dialog_holo_light_frame"



来源:https://stackoverflow.com/questions/17843922/layout-like-cards-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!