Skip to content

DropDown XML Layout

dips25 edited this page Jan 28, 2024 · 1 revision

Welcome to the DropDownMenu wiki!

 <LinearLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">

**<!---Creating the DropDownMenu--->**

<com.view.menu.mydropdown.MyDropDownMenu

 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginStart="5dp"
 android:layout_marginEnd="5dp"
 android:layout_marginTop="5dp"
 app:heading="Image"------------**Header Text**
 android:textStyle="italic|bold"---------**Header Text Style**
 app:headertextColor="#808080"-----------**Add header text Color. Default is black**
 app:headerTextSize="10"-------------**Add header textSize.Default is 12sp**
 android:gravity="center"
 app:labelPosition="center"-----------**Add headertext gravity inside your header **
 app:curved="true"--------------------**Add curved behaviour.By default set to false**
 app:outerborder="true"---------------**Add border.By default set to false**
 app:outerborderColor="@color/gray"-----**Add outerborderColor.By default set to black**
 app:outerborderWidth="3"---------------**Add border width.By default set to 2dp**
 app:header="@drawable/lockdoor"---------**Add header background.You can also use a custom layout(@layout/header) of your own or any color(@color/pink).**
 app:addDropDownIcon="true"------------**Add drop down icon.By default set to false**
 app:dropDownResource="@drawable/dropdowniconn"------**Add your own drawable resource as dropdown.**
 android:id="@+id/mydropdown">

Add an ImageView

 <ImageView
     android:layout_width="match_parent"
     android:layout_height="250dp"
     android:layout_marginTop="10dp"
     android:background="@drawable/lockdoor"/>

Add another dropdown as a child of the first dropdown

 <com.view.menu.mydropdown.MyDropDownMenu
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_marginTop="10dp"
     app:curved="true"
     app:outerborder="true"
     app:outerborderWidth="5"
     app:addDropDownIcon="true"
     app:labelPosition="center_bottom"
     app:headerTextSize="14"
    app:headertextColor="@color/material_dynamic_neutral40"
     app:outerborderColor="@color/black"
     app:header="@color/gray"
     android:layout_centerVertical="true"
     app:heading="What is Lorem Ipsum?"
     android:id="@+id/innerlayout">

     <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/sampletext"/>

</com.view.menu.mydropdown.MyDropDownMenu>

</com.view.menu.mydropdown.MyDropDownMenu>

  ** <!--Create a second dropdown-->**

     <com.view.menu.mydropdown.MyDropDownMenu
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="20dp"
         android:layout_marginStart="5dp"
         android:layout_marginEnd="5dp"
         app:curved="true"
         app:outerborder="true"
         app:labelPosition="center"
         app:heading="2ndMenu"
         app:header="@drawable/lockdoor"
         app:outerborderWidth="6"
         app:headertextColor="@color/black"
         app:addDropDownIcon="true"
         android:id="@+id/secondmenu">

Add an ImageView and Button.You can also place any other views.

         <ImageView
             android:layout_width="match_parent"
             android:layout_height="350dp"
             android:layout_marginTop="10dp"
             android:background="@drawable/sampleheader"
             android:scaleType="fitXY"/>

         <Button
                     android:layout_width="match_parent"
                     android:layout_height="60dp"
                     android:text="GetAllValues"
                     android:layout_gravity="bottom"
                     android:id="@+id/getselectedvalues"/>

     </com.view.menu.mydropdown.MyDropDownMenu>


 </LinearLayout>

Clone this wiki locally