KyoSherlock / ExpandableLayout

ExpandableLayout for Android
103 stars 29 forks source link

Some compressed elements in LinearLayout when I expand ExpandableLayout below #9

Open ferPrieto opened 8 years ago

ferPrieto commented 8 years ago

I am using a RecyclerView to show some elements and comparing to your sample I don't see the error. The adapter, that I am using, has some layouts inside it and when I expand the textView I defined as expandable it shows this text perfectly, but the rest elements are compressed... This is my xml:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="?attr/selectableItemBackground">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include layout="@layout/layout_top_timeline" />

    <include layout="@layout/layout_middle_timeline" />

    <include layout="@layout/layout_bottom_timeline" />

    <TextView
        android:id="@+id/description_video" 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginLeft="14dp"
        android:layout_weight="0.13"
        android:text="@string/txt_timeline"
        android:textColor="#484b4c"
        android:textSize="14sp" />

    <com.kyo.expandablelayout.ExpandableLayout
        android:id="@+id/expandable_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/description_expanded"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14dp"
            android:text="@string/txt_timeline"
            android:textColor="#484b4c"
            android:textSize="14sp"
            app:canExpand="true" />
    </com.kyo.expandablelayout.ExpandableLayout>

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

    <TextView
        android:id="@+id/bt_view_all"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1"
        android:background="@null"
        android:gravity="center"
        android:scaleType="fitCenter"
        android:text="View all" />

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

</LinearLayout>

<FrameLayout
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_marginLeft="14dp"
    android:layout_marginTop="9dp">

    <ImageView
        android:id="@+id/iv_user_picture"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:src="@drawable/icon_profile_picture_placeholder"
        app:srcCompat="@drawable/icon_profile_picture_placeholder" />

    <ImageView
        android:id="@+id/iv_reaction_emoji"
        android:layout_width="@dimen/default_icon_button"
        android:layout_height="@dimen/default_icon_button"
        android:contentDescription="@string/cd_reaction_face"
        android:scaleType="fitXY" />
</FrameLayout>

In java there is nothing special to show... I only call toggleExpansion() to do it. Using weights in your sample it works perfectly, but not in my case...Thanks

KyoSherlock commented 8 years ago

If the compressed elements are TextView using weights(@+id/description_video and @+id/bt_view_all), this is a normal result, even if it's not what you want. The weight uses the remaining space that will change in this case.