Git Product home page Git Product logo

Comments (7)

cachapa avatar cachapa commented on August 16, 2024

Your XML isn't complete. It's missing at least the parent layout.
Can you post the entire layout?

from expandablelayout.

tangible-idea avatar tangible-idea commented on August 16, 2024

@cachapa
representation1 : https://youtu.be/yJ7ZIQWG3no

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/expand_button_0"
    android:layout_width="match_parent"
    android:layout_height="82dp"
    android:background="#f8f8f8"
    android:foreground="?selectableItemBackground">

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/img_region"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="29dp"
        android:layout_marginBottom="29dp"
        android:src="@drawable/ic_plan_region"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/title_region"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="21dp"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="30dp"
        android:lineSpacingExtra="12sp"
        android:text="Region"
        android:textAlignment="viewStart"
        android:textAppearance="@style/region_demi_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toEndOf="@+id/img_region"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

    <net.cachapa.expandablelayout.ExpandableLayout
        android:id="@+id/expandable_layout_0"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:el_duration="300"
        app:el_expanded="true">

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

    </net.cachapa.expandablelayout.ExpandableLayout>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/expand_button_1"
    android:layout_width="match_parent"
    android:layout_height="82dp"
    android:background="#f8f8f8"
    android:foreground="?selectableItemBackground">

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/img_datetime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="29dp"
        android:layout_marginBottom="29dp"
        android:src="@drawable/ic_plan_region"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="21dp"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="30dp"
        android:lineSpacingExtra="12sp"
        android:text="Date / Time"
        android:textAlignment="viewStart"
        android:textAppearance="@style/region_demi_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toEndOf="@+id/img_datetime"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

    <net.cachapa.expandablelayout.ExpandableLayout
        android:id="@+id/expandable_layout_1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:el_duration="300"
        app:el_expanded="false">

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

    </net.cachapa.expandablelayout.ExpandableLayout>


<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/expand_button_2"
    android:layout_width="match_parent"
    android:layout_height="82dp"
    android:background="#f8f8f8"
    android:foreground="?selectableItemBackground">

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/img_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="29dp"
        android:layout_marginBottom="29dp"
        android:src="@drawable/ic_plan_message"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/title_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="21dp"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="30dp"
        android:lineSpacingExtra="12sp"
        android:text="Message"
        android:textAlignment="viewStart"
        android:textAppearance="@style/region_demi_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toEndOf="@+id/img_message"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

        <net.cachapa.expandablelayout.ExpandableLayout
            android:id="@+id/expandable_layout_2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            app:el_duration="300"
            app:el_expanded="false">

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

        </net.cachapa.expandablelayout.ExpandableLayout>

from expandablelayout.

tangible-idea avatar tangible-idea commented on August 16, 2024

@cachapa
representation2 : https://youtu.be/xQ8HoWWdPOU

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

    <TextView
        android:id="@+id/expand_button_0"
        style="@style/TextAppearance.AppCompat.Medium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#00b300"
        android:elevation="6dp"
        android:foreground="?selectableItemBackground"
        android:gravity="center"
        android:padding="16dp"
        android:text="Tap to toggle expansion"
        android:textColor="#fff" />

    <net.cachapa.expandablelayout.ExpandableLayout
        android:id="@+id/expandable_layout_0"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:el_duration="500"
        app:el_expanded="false">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#009900"
            android:clipToPadding="false"
            android:elevation="4dp"
            android:gravity="center"
            android:text="Fixed height"
            android:textColor="#fff" />

    </net.cachapa.expandablelayout.ExpandableLayout>

</LinearLayout>

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

    <TextView
        android:id="@+id/expand_button_1"
        style="@style/TextAppearance.AppCompat.Medium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#00f"
        android:elevation="6dp"
        android:foreground="?selectableItemBackground"
        android:gravity="center"
        android:padding="16dp"
        android:text="Tap to toggle expansion"
        android:textColor="#fff" />

    <net.cachapa.expandablelayout.ExpandableLayout
        android:id="@+id/expandable_layout_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:el_duration="500"
        app:el_expanded="true">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#0000e6"
            android:clipToPadding="false"
            android:elevation="4dp"
            android:gravity="center"
            android:text="Fixed height"
            android:textColor="#fff"/>

    </net.cachapa.expandablelayout.ExpandableLayout>

</LinearLayout>

from expandablelayout.

cachapa avatar cachapa commented on August 16, 2024

That's still not the entire XML. It's missing the parent layout tag.

from expandablelayout.

tangible-idea avatar tangible-idea commented on August 16, 2024

@cachapa
Sorry, I tried to copy and paste but it didn't work properly.

https://s3-eu-west-1.amazonaws.com/tangibleidea.net/activity_plan_old.xml
https://s3-eu-west-1.amazonaws.com/tangibleidea.net/activity_plan.xml
here are the links of issues xml files.

from expandablelayout.

cachapa avatar cachapa commented on August 16, 2024

Ok, so it seems the issue is that you can't have an "accordion" animation with LinearLayout weights.
ExpandableLayout needs to know its calculated height so it can animate between states. That height is requested from its parent layout, in this case, LinearLayout.

When you animate two layouts simultaneously (in order to create the accordion effect), both layouts are visible at the same time, which causes the parent LinearLayout to attribute 50% of its height to each ExpandableLayout.

ExpandableLayout is behaving correctly here, as it's delegating his size calculations to its parent. I'm not sure how to achieve the effect you want, but you might have to go with a different route, like layout transitions or custom animations. It might make sense to ask this in StackOverflow.

In any case it isn't an issue with ExpandableLayout so I'm closing this.

from expandablelayout.

tangible-idea avatar tangible-idea commented on August 16, 2024

@cachapa
What parent layout should I use then? only fixed height supported so far?
What about layout_constraintHeight_percent with ConstraintLayout

from expandablelayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.