Add it in your root build.gradle at the end of repositories:
buildscript {
repositories {
maven { url "https://jitpack.io" }
}
}
Add the dependency:
compile 'com.github.tipsi:tipsi-dropdown-android:0.4'
In near future dropdown will support customization using the following code:
Style style = new Style.Builder()
.withBackgroundColor("0x0000FF")
.withBorderWidth(2)
.withBorderColor("0xFFFFFF")
.withCornerRadius(10)
.withSeparatorHeight(1)
.withSeparatorColor("0xAAAAAA")
.withFontSize(15)
.withTextColor("0xCCCCCC")
.withTextAlignment("Left")
.withIndicatorImageName("custom_triangle") // image should be located in drawable
.withIndicatorImageResId(R.drawable.custom_triangle) // or via resource id
.build();
Adding dropdown into layout:
<com.gettipsi.tpsdropdown.DropdownContainer
android:id="@+id/dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Applying style to dropdown
((DropdownContainer) findViewById(R.id.dropdown)).setStyle(style);
You can also extend default class Adapter and set it with
((DropdownContainer) findViewById(R.id.dropdown)).setupWithAdapter(customAdapter);
or init with list of elements
List<String> items = Arrays.asList("One", "Two", "Three", "Four");
((DropdownContainer) findViewById(R.id.dropdown)).setupWithAdapter(items);
Tipsi team
TipsiDropdown is available under the MIT license. See the LICENSE file for more info.