0

I have problem with changing Exapandable layout params. I'm using layout from this library: https://github.com/AAkira/ExpandableLayout

I put ImageView inside this layout and than when I download picture into ImageView I want my layout to wrap this image.

<com.github.aakira.expandablelayout.ExpandableRelativeLayout
            android:id="@+id/expandable_area"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_below="@+id/event_accepted_people_scrollview"
            android:layout_alignParentStart="true">

                <android.support.v7.widget.AppCompatImageView
                    android:id="@+id/card_map_icon"
                    android:layout_width="70dp"
                    android:layout_height="70dp"
                    app:srcCompat="@drawable/vector_drawable_ic_map_black___px"
                    android:tint="@color/skilltrade_grey"
                    android:scaleType="center"
                    android:layout_marginTop="5dp"
                    android:layout_centerHorizontal="true"
                    android:background="@drawable/ripple_effect"/>

                <TextView
                    android:id="@+id/no_map_snapshot_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/no_map_snapshot"
                    android:gravity="center_horizontal"
                    android:layout_marginBottom="15dp"
                    android:layout_below="@id/card_map_icon"/>


                <ImageView
                    android:id="@+id/carditem_map_snapshot"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/details_map_textview"
                    android:scaleType="center"
                    android:layout_marginTop="5dp" />

        </com.github.aakira.expandablelayout.ExpandableRelativeLayout>

Problem is that layout wraps only AppCompatImageView and TextView because ImageView source is not set and it's height is 0. After downloading picture layout is not wraping content correctlly...

That's what I'm doing now:
-I download picture in size 640x480.
-Than I scale it to match my screen
-After that when I know height of my image I change params of my Expandable layout like this:

RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mapSnapshot.getLayoutParams();
        params.width = width;//scaled picture width
        params.height = height;//scaled picture height
        mapSnapshot.setLayoutParams(params);
        expandableArea.updateViewLayout(mapSnapshot, params);

Unfortunately it's not working and layouts height is still not matching ImageView...

I would be grateful for any help :)

Zygi
  • 754
  • 8
  • 17
  • check parent layout and then set SameViewGroup Layout prams .....OR add RelativeLayout layout before your ExpandableRelativeLayout – sushildlh Sep 08 '16 at 13:30
  • Adding relative layout before ExpandableRelativeLayout is not helping. @sushildlh What do you mean about checking parent layout? – Zygi Sep 08 '16 at 13:37
  • try ExpandableRelativeLayout.Pramas instead of RelativeLayout.Pramas .... – sushildlh Sep 08 '16 at 13:39
  • I tried that already. I also tried to set layout params separatly not with expandableArea.updateViewLayout(mapSnapshot, params); – Zygi Sep 08 '16 at 13:42

0 Answers0