Content layout does not match expandable layout width
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
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.
same problem happens to me, content layout is wrapped even though i'm using match_parent, and the suggested solution didnot work out.
@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.
i'm having the same issue, could you please upload a code which changes the content layout width at runtime? thanks :)
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 I can confirm you do not have to do this much.
Just put your LinearLayout in RelativeLayout. It does the job for me.
thank you @anaszakariyah and @hendraanggrian for the quick answers, the second option did the job for me!
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 >