GithubHelp home page GithubHelp logo

expandmenu's Introduction

Android可展开收起的菜单栏

属性名称 含义 属性类型
back_color 菜单栏背景颜色 color
stroke_size 菜单栏边框粗细 dimension
stroke_color 菜单栏边框颜色 color
corner_radius 菜单栏边框圆角半径 dimension
button_style 按钮类型(居左或右) left | right
button_icon_size 按钮icon大小 dimension
button_icon_stroke_width 按钮icon粗细 dimension
button_icon_color 按钮icon颜色 color
expand_time 菜单栏展开收起动画时长(毫秒) integer
  • 效果展示:

  • 示例布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="15dp"
            android:text="默认菜单栏样式"/>
        <com.anlia.expandmenu.widget.HorizontalExpandMenu
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:clickable="true">
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item1"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item2"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item3"/>
            </LinearLayout>
        </com.anlia.expandmenu.widget.HorizontalExpandMenu>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="20dp"
            android:text="按钮在左侧"/>
        <com.anlia.expandmenu.widget.HorizontalExpandMenu
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            app:button_style="left">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:clickable="true">
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item1"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item2"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item3"/>
            </LinearLayout>
        </com.anlia.expandmenu.widget.HorizontalExpandMenu>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="20dp"
            android:text="可设置圆角、描边、阴影、按钮的颜色等等"/>
        <com.anlia.expandmenu.widget.HorizontalExpandMenu
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:elevation="2dp"
            app:corner_radius="10dp"
            app:button_icon_color="@color/red"
            app:stroke_color="@color/red">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:clickable="true">
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item1"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item2"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="item3"/>
            </LinearLayout>
        </com.anlia.expandmenu.widget.HorizontalExpandMenu>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="20dp"
            android:text="可自定义菜单栏里的内容,但只能设置一个直接子元素"/>
        <com.anlia.expandmenu.widget.HorizontalExpandMenu
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp">
            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true"
                android:scrollbars="none">
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal"
                    android:gravity="center_vertical"
                    android:clickable="true">
                    <TextView
                        android:layout_width="100dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:background="@color/blue"
                        android:text="item1"/>
                    <TextView
                        android:layout_width="50dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:background="@color/yellow"
                        android:text="item2"/>
                    <TextView
                        android:layout_width="100dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:background="@color/green"
                        android:text="item3"/>
                    <TextView
                        android:layout_width="150dp"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:background="@color/red"
                        android:text="item4"/>
                </LinearLayout>
            </HorizontalScrollView>
        </com.anlia.expandmenu.widget.HorizontalExpandMenu>
    </LinearLayout>
</RelativeLayout>

expandmenu's People

Contributors

anlialee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.