ExpandableListView将展开模式更改为水平

时间:2014-10-13 15:14:28

标签: android layout expandablelistview

我正在尝试更改ExpandableListView扩展的方式。 默认是垂直的,但我想让它水平扩展!

像这样(http://developer.android.com/design/patterns/multi-pane-layouts.html),但这使用多窗格。

我想要做的是,当点击父母时,孩子将与父母一致,而不是在父母之下。

默认为:

Parent1
  Child1
Parent2
  Child2

我想要的是:

Parent1     Child1
Parent2     Child2

main.xml中:

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.list"
        android:background="#141214"
        >
     <ExpandableListView android:id="@+id/list"
            android:layout_height="match_parent"
            android:layout_width="200dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="?android:attr/actionBarSize"
            android:smoothScrollbar="true"
            android:fadingEdge="vertical"

           />

Parent_View.xml:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
        <CheckedTextView
            xmlns:android="http://schemas.android.com/apk/res/android"

            android:id="@+id/textViewGroupName"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_vertical"

            android:text="@string/hello_world"
            android:textSize="18sp"
            android:textColor="#FFFFFF"
            android:padding="30dp"

            android:textSelectHandleLeft="@string/hello_world"
            android:background="#009999"
            android:textStyle="bold"
             />

Child View.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="#99D6D6"
    android:orientation="vertical"
    android:paddingLeft="40dp"
    android:paddingRight="0dp"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="39dp"
        android:gravity="center_vertical" >



        <TextView
            android:id="@+id/textViewChild"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/hello_world"
            android:textSize="16sp"
            android:textColor="#1919A3"
            android:textStyle="bold" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@android:color/white" />

</LinearLayout>

那么有没有办法修改ExpandableListView属性,以便子项与父项一致?

有什么想法吗? 谢谢

0 个答案:

没有答案