Provare il layout espandibile here. Si può avere lo stesso comportamento come Accordian
includerlo al vostro Gradle con compile 'com.github.aakira:expandable-layout:[email protected]'
Esempio
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/accordian_header"
android:clickable="true">
<TextView
android:id="@+id/accordian_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textColor="#333"
android:textStyle="bold"
android:text="Title" />
<ImageButton
android:id="@+id/down_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="8dp"
android:src="@android:drawable/arrow_down_float" />
</RelativeLayout>
<com.github.aakira.expandablelayout.ExpandableLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:paddingBottom="14dp"
android:orientation="vertical"
android:id="@+id/content"
app:ael_expanded="false"
app:ael_duration="500"
app:ael_orientation="vertical">
<!--add your content here -->
</com.github.aakira.expandablelayout.ExpandableLinearLayout>
</LinearLayout>
Poi, nel tuo codice Java
ExpandableLinearLayout content=(ExpandableLinearLayout) itemView.findViewById(R.id.content);
RelativeLayout header=(RelativeLayout) itemView.findViewById(R.id.accordian_header);
//to toggle content
header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
content.toggle();
}
});
Speranza che è stato utile.
fonte
2016-06-05 01:38:05