可扩展的布局

时间:2016-08-29 15:23:44

标签: android android-layout relativelayout expandable

我对可扩展布局(https://android-arsenal.com/details/1/2456)有疑问。 当应用程序启动时,片段被插入@id(flContent),ExpandableRelativeLayout被折叠(因为app:ael_expanded =" false")我可以通过点击@id / cerca_button_advanced展开和折叠它。 当使用NavigationView中的菜单加载另一个片段然后再加载第一个片段时,ExpandableRelativeLayout仍然会展开。 为什么它仍然会扩展,即使app:ael_expanded =" false"?我希望有人可以帮助我...

这是activity_main.xml

<!-- This DrawerLayout has two children at the root  -->
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <!-- This LinearLayout represents the contents of the screen  -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <!-- The ActionBar displayed at the top -->
        <include
            layout="@layout/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
        <!-- The main content view where fragments are loaded -->
        <FrameLayout
            android:id="@+id/flContent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout>
    <!-- The navigation drawer that comes from the left -->
    <!-- Note that `android:layout_gravity` needs to be set to 'start' -->
    <android.support.design.widget.NavigationView
        android:id="@+id/nvView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>

这是在@ id / flContent

中插入的fragment.xml
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginStart="5dp"
            android:layout_marginTop="5dp"
            card_view:cardElevation="2dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="5dp">
                <TableLayout
                    android:id="@+id/cerca_tabella"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:shrinkColumns="1"
                    android:stretchColumns="1">
                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <TextView
                            android:id="@+id/cerca_testo_nome"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:labelFor="@+id/cerca_input_nome"
                            android:text="@string/cerca_descrizione_nome"/>
                        <EditText
                            android:id="@+id/cerca_input_nome"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:inputType="textNoSuggestions|textCapSentences|text"/>
                    </TableRow>
                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <TextView
                            android:id="@+id/cerca_testo_via"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:labelFor="@+id/cerca_input_via"
                            android:text="@string/cerca_descrizione_indirizzo"/>
                        <EditText
                            android:id="@+id/cerca_input_via"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:inputType="textNoSuggestions|text|textPostalAddress"/>
                    </TableRow>
                    <TableRow
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <TextView
                            android:id="@+id/cerca_testo_citta"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:labelFor="@+id/cerca_input_citta"
                            android:text="@string/cerca_descrizione_citta"/>
                        <Spinner
                            android:id="@+id/cerca_spinner_citta"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:entries="@array/cerca_citta"/>
                    </TableRow>
                </TableLayout>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp">
                    <RelativeLayout
                        android:id="@+id/cerca_button_advanced"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <View
                            android:id="@+id/cerca_button_advance_logo"
                            android:layout_width="14dp"
                            android:layout_height="14dp"
                            android:layout_alignParentStart="true"
                            android:layout_marginEnd="5dp"
                            android:layout_marginStart="5dp"
                            android:background="@drawable/triangolo"
                            />
                        <TextView
                            android:id="@+id/cerca_button_advance_text"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignBottom="@+id/cerca_button_advance_logo"
                            android:layout_toEndOf="@+id/cerca_button_advance_logo"
                            android:text="Advanced"
                            />
                    </RelativeLayout>
                    <com.github.aakira.expandablelayout.ExpandableRelativeLayout
                        xmlns:app="http://schemas.android.com/apk/res-auto"
                        android:id="@+id/expandable_layout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/cerca_button_advanced"
                        app:ael_duration="500"
                        app:ael_expanded="false"
                        app:ael_interpolator="decelerate"
                        app:ael_orientation="vertical">
                        <Switch
                            android:id="@+id/switch1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="New Switch 1"/>
                        <Switch
                            android:id="@+id/switch2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/switch1"
                            android:text="New Switch 2"/>
                    </com.github.aakira.expandablelayout.ExpandableRelativeLayout>
                </RelativeLayout>
            </LinearLayout>
        </android.support.v7.widget.CardView>
        <my.AdapterLinearLayout
            android:id="@+id/cerca_linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical"/>
    </LinearLayout>
</ScrollView>

0 个答案:

没有答案