Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.mahimrocky:ExpandableCardView:1.0.1'
}
dependencies {
implementation("com.github.mahimrocky:ExpandableCardView:1.0.1")
}
<dependency>
<groupId>com.github.mahimrocky</groupId>
<artifactId>ExpandableCardView</artifactId>
<version>1.0.1</version>
</dependency>
libraryDependencies += "com.github.mahimrocky" % "ExpandableCardView" % "1.0.1"
:dependencies [[com.github.mahimrocky/ExpandableCardView "1.0.1"]]
Sample
Following instructions you have to follow to use Expandable Card view
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.mahimrocky:ExpandableCardView:1.0.1'
}
<com.skyhope.expandcollapsecardview.ExpandCollapseCard
android:id="@+id/collapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:item_inner_view="@layout/item_text"
app:title="This is title"
app:title_color="#000000"
app:title_size="16sp" />
| Attributes | Purpose |
| ------ | ------ |
| app:title
| To change main title|
| app:title_size
| To change main title size|
| app:title_color
| To change main title color|
| app:title_background_color
| To change title bar background color|
| app:expand_icon
| To change expand icon|
| app:collapse_icon
| To change collapse icon|
| app:item_inner_view
| To set your custom inner view|
| Method | Purpose |
| ------ | ------ |
|setTitleTextColor(int color)
| Change title text color|
|setTitleText(String text)
| Change title text|
|getChildView()
| This method give you your innerview reference by this you can change or find your inner view property|
|isExpand()
| To find card is expand opr not|
So here is a trick to get your inner layout others or child view access. You have t use getChildView()
method. Its give you a view
By this view
you will get your inner view property. Example:
Button btn = (Button)view.findViewById(R.id.button_id);
Implement ExpandCollapseListener
In your activity or fragment section
and call
ExpandCollapseCard collapseCard = findViewById(R.id.collapse);
collapseCard.initListener(this);
you will get this like
@Override
public void onExpandCollapseListener(boolean isExpand) {
Log.d("expand_listener", "isExpand: " + isExpand);
}