2016-12-30 30 views

回答

3

我找到了解决办法。

把东西就像在你的布局文件中的以下

<com.github.aakira.expandablelayout.ExpandableRelativeLayout 
      android:id="@+id/expandableLayout4" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/expandableButton4" 
      android:background="#ffcc80" 
      android:padding="16dp" 
      app:ael_duration="400" 
      app:ael_expanded="false" 
      app:ael_interpolator="accelerate" 
      app:ael_orientation="vertical"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="#FFFFFF" 
       android:text="Things to put in the expandable layout" /> 
     </com.github.aakira.expandablelayout.ExpandableRelativeLayout> 

添加到您的构建gradle这个文件

dependencies { 
compile 'com.github.aakira:expandable-layout:[email protected]'} 

设置的onClick监听器拓展布局的方式

public void expandableButton1(View view) { 
    expandableLayout1 = (ExpandableRelativeLayout) findViewById(R.id.expandableLayout1); 
    expandableLayout1.toggle(); // toggle expand and collapse 
} 

更多详细说明:http://www.codeisall.com/android-expandable-layout/