Comments (7)
Your XML isn't complete. It's missing at least the parent layout.
Can you post the entire layout?
from expandablelayout.
@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.
@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.
That's still not the entire XML. It's missing the parent layout tag.
from expandablelayout.
@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.
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.
@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)
- Expandable Layout not working in coordinator layout, But working smoothly in linear layout HOT 6
- Resetting child view when expanding other view HOT 4
- At a time one expand HOT 2
- Can I expand multiple views at the same time? HOT 3
- Request: Linear layout as root. HOT 3
- Scroll RecyclerView to show selected item expand on top HOT 1
- Indication Markers HOT 1
- Starting expanded HOT 1
- Start expanded HOT 1
- Move away from JCenter HOT 1
- library wont expand on androidx.constraintlayout:constraintlayout:2.0.4 HOT 1
- JCenter is scheduled for closing HOT 1
- mavenCentral() support HOT 1
- mavenCentral() support HOT 1
- Toggle with out clicking on expandable view
- toped working after went to MavenCentral() HOT 3
- How can expand the fist group programatically? HOT 1
- Scrolling to item position is not working
- Unable to download dependency from Maven HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandablelayout.