ExpandableLayout icon indicating copy to clipboard operation
ExpandableLayout copied to clipboard

Content layout does not match expandable layout width

Open anaszakariyah opened this issue 10 years ago • 8 comments

Header layout using relative layout with layout_width="match_parent" is viewed just fine, match with expandable layout. But, I am using linear layout with layout_width="match_parent" in content layout and it does not match parent, rather it is wrapped. Do I have to use relative layout to match it with parent or is there other solution?

Regards, anas

btw, great codes. Thank you, i am using the library for my project :D

anaszakariyah avatar Jul 08 '15 05:07 anaszakariyah

Hi anas, i am currently using this library and was having the same issue. I have a solution for this. I investigated the view hierarchy and found that at run time the header and content layout are changed to frame layout. Hence setting the layout width and height at runtime as FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT will solve the issue.

nicolas113 avatar Jul 22 '15 03:07 nicolas113

same problem happens to me, content layout is wrapped even though i'm using match_parent, and the suggested solution didnot work out.

silviahisham avatar Nov 23 '15 11:11 silviahisham

@silviahisham did you change your layout parameters after the UI is rendered? I used tree observer to change the layout in runtime. Another direction would be dumping the layout at runtime and check which width parameter was incorrectly set.

nicolas113 avatar Nov 26 '15 03:11 nicolas113

i'm having the same issue, could you please upload a code which changes the content layout width at runtime? thanks :)

lim305656563 avatar Dec 20 '15 21:12 lim305656563

The ExpandableLayout automatically wrap the content if you are using solely linear layout even if you set the content as MATCH_PARENT. One solution is change it at runtime as nicolas proposed. But then again, I prefer solely use xml if possible to design rather than edit it at runtime. So, I found a bit hack for this.

Put the Linearlayout inside relativelayout, make two Views with zero size, and latch one to the right and one to the left side of relative layout. I know it is not so neat, but I think it will do since I dont have to programatically change the size.

Hope it will help.

Regards,

Moh. Anas Zakariyah

On Sun, Dec 20, 2015 at 1:05 PM -0800, "lim305656563" [email protected] wrote:

i'm having the same issue, could you please upload a code which changes the content layout width at runtime?

thanks :)

— Reply to this email directly or view it on GitHub.

anaszakariyah avatar Dec 21 '15 18:12 anaszakariyah

@anaszakariyah I can confirm you do not have to do this much.

Just put your LinearLayout in RelativeLayout. It does the job for me.

hanggrian avatar Dec 23 '15 10:12 hanggrian

thank you @anaszakariyah and @hendraanggrian for the quick answers, the second option did the job for me!

lim305656563 avatar Dec 23 '15 17:12 lim305656563

Sample

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:background="@color/grape"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textViewStatsTeamA"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left" />

        <TextView
            android:id="@+id/textViewStatsTeamB"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="left" />

    </LinearLayout >

</RelativeLayout >

gelldur avatar Feb 11 '16 15:02 gelldur