Search code examples
androidpanels

How to create this type of panels in Android?


I've seen this type of panels (white ones with the shadow border at the bottom) and I would like to use them in my apps.

https://lh6.ggpht.com/i_RUUvI7G2UM1eBn5hAcJQvqK_K1tHMiw7ynAc4hwwUD1_J1g03MkMBaFu0n5jA2YA=h900-rw

What kind of panels are and How can I create them?

Thanks in advance


Solution

  • /drawable/panel_bg.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <!-- Bottom 3dp Shadow -->
        <item>
            <shape android:shape="rectangle">
    
            <solid android:color="#C7C6C5" />
            <corners android:radius="4dp" />
    
        </shape>
        </item>
    
        <!-- White Top color -->
        <item android:bottom="4px">
    
            <shape android:shape="rectangle">
    
            <solid android:color="@color/white" />
            <corners android:radius="4dp" />
    
    
            </shape>
    
        </item>
    
    </layer-list>
    

    /layout/test.xml

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <LinearLayout
            android:id="@+id/LinearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
    
            <LinearLayout
                android:id="@+id/LinearLayout2"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/panel_bg"
                android:orientation="vertical" >
    
                <TextView
                    android:id="@+id/tv1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:text="Hello world"
                    android:textColor="#cccccc"
                    android:textSize="14sp" />
    
                <TextView
                    android:id="@+id/tv2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="1234567890"
                    android:textColor="#cccccc"
                    android:textSize="14sp" />
            </LinearLayout>
    
            <LinearLayout
                android:id="@+id/LinearLayout3"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/panel_bg"
                android:orientation="vertical" >
    
               <TextView
                    android:id="@+id/tv3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="4dp"
                    android:text="Hellllooo"
                    android:textSize="16sp" />
    
                <TextView
                    android:id="@+id/tv4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="ashkdhakhd"
                    android:textColor="#38B6AB"
                    android:textSize="32sp" />
            </LinearLayout>
        </LinearLayout>
    
    </ScrollView>
    

    or you can create custom listView