Ane*_*een 8 android material-design
我只是在寻找android(材料设计)中的扩展面板的示例.
https://www.google.com/design/spec/components/expansion-panels.html
我知道我们有可扩展的列表视图.但是,我需要在扩展每个面板时显示一些额外的布局视图,类似于Accordian视图.我们怎样才能在android中实现这一点?
在这里尝试可扩展的布局.它可以与Accordian具有相同的行为
用示例将它包含在您的gradle中compile 'com.github.aakira:expandable-layout:1.5.1@aar'
<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>
Run Code Online (Sandbox Code Playgroud)
然后在你的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();
}
});
Run Code Online (Sandbox Code Playgroud)
希望这很有帮助.
| 归档时间: |
|
| 查看次数: |
9468 次 |
| 最近记录: |