Giter Club home page Giter Club logo

dropdown's Introduction

Simple Dropdown TextView For Android

Getting Started

To start working with dropdown, you need to add its dependency into your build.gradle file:

Dependency

dependencies {
    implementation "com.github.farasource:dropdown:[latest_version]"
}

Then you need to add jitpack as your maven repository:

  • New method add in settings.gradle file:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
  • Old method add in build.gradle file:
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Sample

There is a fully functional sample application that demonstrates the usage of dropdown, all you have to do is cloning the project and running the sample module.

How to use

Use dropdown in the layout pragmatically

DropdownView dropdownView = new DropdownView(context);
dropdownView.setExpanded(false); // or setExpanded(false, /* animate */true)
dropdownView.setElevation(0);
dropdownView.setCardCornerRadius(10);
dropdownView.setCardBackgroundColor(getResources().getColor(R.color.colorPrimary)); // or setCardBackground(drawable)
dropdownView.setCardBackgroundColorExpanded(getResources().getColor(R.color.colorPrimary)); // option
dropdownView.setArrow(com.farasource.component.dropdown.R.drawable.ic_round_arrow_right_24); // or setArrow(drawable)
dropdownView.setArrowTint(Color.WHITE);
dropdownView.setArrowTintExpanded(Color.WHITE); // option
dropdownView.setArrowRotation(DropdownView.QUARTER);
dropdownView.setUseDivider(false);
dropdownView.setDividerColor(0xffe2e2e2);
dropdownView.setDividerHeight(1);
dropdownView.setTitleBackgroundColorExpanded(Color.TRANSPARENT);
dropdownView.setTitleText("Hello world!");
dropdownView.setTitleTextColor(Color.WHITE);
dropdownView.setTitleTextColorExpanded(Color.WHITE); // option
dropdownView.setTitleTextSize(17);
//dropdownView.setTitleTypeface(typeface); // or setTitleTypeface(typeface, /* bold */ true)
dropdownView.setContentText("World world world world world..."); // or setHtmlContent(content)
dropdownView.setContentTextColor(Color.WHITE);
dropdownView.setContentTextSize(17);
//dropdownView.setContentTypeface(typeface); // or setContentTypeface(typeface, /* bold */ false)

Use dropdown in the layout via xml

<com.farasource.component.dropdown.DropdownView
    android:id="@+id/dropdown"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginHorizontal="10dp"
    android:layout_marginTop="10dp"
    android:elevation="3dp"
    app:arrow="@drawable/ic_round_arrow_right_24"
    app:arrowRotation="quarter"
    app:arrowTint="@color/white"
    app:arrowTintExpanded="@color/white"
    app:cardBackground="@color/colorPrimary"
    app:cardBackgroundExpanded="@color/colorPrimary"
    app:cardCornerRadius="10dp"
    app:contentText="@string/def_text"
    app:contentTextBold="false"
    app:contentTextColor="@color/white"
    app:contentTextFont="fonts/font.ttf"
    app:contentTextSize="17dp"
    app:dividerColor="#e2e2e2"
    app:dividerHeight="1dp"
    app:elevation="0dp"
    app:expanded="false"
    app:titleBackgroundExpanded="@color/colorPrimary"
    app:titleText="@string/app_name"
    app:titleTextBold="true"
    app:titleTextColor="@color/white"
    app:titleTextColorExpanded="@color/white"
    app:titleTextFont="fonts/font.ttf"
    app:titleTextSize="17dp"
    app:useDivider="false" />

Author & support

This project was created by Abbas Ghasemi.

You can help us to keep my open source projects up to date!

dropdown's People

Stargazers

 avatar

Watchers

 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.