Is there an easy way to create expandable / dropable blocks, for example, in the official app on the market?
A screenshot of the Market application, when you click the "Advanced" button, the description section expands with animation:

I know SlidingDrawer , but it does not seem to be suitable for such things - it should be placed in the overlay, and does not support semi-open states.
Update:
Here is my semi-tasking solution. This is a custom widget that extends LinearLayout . This is a kind of work, but it does not handle boundary cases very well, for example, the content height is less than the collapsedHeight parameter. I am sure that with sufficient attention I look, dig code and experimenting that quirks can be fixed. I was hoping to avoid this and save some time using a ready-made official or third-party solution. Anyway, here it is, the code:
package com.example.androidapp.widgets; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LinearLayout; import com.example.androidapp.R; public class ExpandablePanel extends LinearLayout { private final int mHandleId; private final int mContentId; private View mHandle; private View mContent; private boolean mExpanded = true; private int mCollapsedHeight = 0; private int mContentHeight = 0; public ExpandablePanel(Context context) { this(context, null); } public ExpandablePanel(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ExpandablePanel, 0, 0);
Here res/values/attrs.xml :
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="ExpandablePanel"> <attr name="handle" format="reference" /> <attr name="content" format="reference" /> <attr name="collapsedHeight" format="dimension" /> </declare-styleable> </resources>
And this is how I use it in the layout:
<com.example.androidapp.widgets.ExpandablePanel android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent" example:handle="@+id/expand" example:content="@+id/value" example:collapsedHeight="50dip"> <TextView android:id="@id/value" android:layout_width="fill_parent" android:layout_height="wrap_content" android:maxHeight="50dip" /> <Button android:id="@id/expand" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="More" /> </com.example.androidapp.widgets.ExpandablePanel>
android widget
PΔteris Caune Mar 02 2018-11-11T00: 00Z
source share