android - Multiline button breaks width calculation of Dialog -



android - Multiline button breaks width calculation of Dialog -

i have ugly error in app , have no thought how prepare it. see @ first 2 screenshots:

as might can see there 1 button big text wraps (that text cutting not matter here). guess text causes calculations bug in linearlayout: in 1 of measure steps width cumulated, width bigger aviable space, take hole width instead of using aviable width , split on elements.

here xml:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:layout_width="match_parent" android:layout_height="@dimen/list_item_height" android:textsize="18sp" android:gravity="center_vertical" android:text="test 1" android:paddingleft="@dimen/dialog_horizontal_margin" android:paddingright="@dimen/dialog_horizontal_margin"/> <linearlayout style="@style/slidebuttoncontainer" android:orientation="horizontal"> <button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="yes"/> <button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="no"/> <button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="maybe"/> </linearlayout> <textview android:layout_width="match_parent" android:layout_height="@dimen/list_item_height" android:textsize="18sp" android:gravity="center_vertical" android:paddingleft="@dimen/dialog_horizontal_margin" android:paddingright="@dimen/dialog_horizontal_margin" android:text="test 2"/> <linearlayout style="@style/slidebuttoncontainer" android:orientation="horizontal"> <button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="one"/> <button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="more 1 million"/> <button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="infinity"/> </linearlayout> </linearlayout>

finally here missing style:

<style name="slidebuttoncontainer"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:paddingleft">@dimen/dialog_horizontal_margin</item> <item name="android:paddingright">@dimen/dialog_horizontal_margin</item> <item name="android:background">#44000000</item> <item name="android:baselinealigned">false</item> </style>

do guys have thought how prepare layout issue?

i had similar problem in project. solution add together wrapper linear layout , assign weight it. on inner button set width , height match_parent. have root layout width wrap content button big text takes biggest space , space height of parent. other smaller buttons extend available height. code should explain more clearly:

<linearlayout android:layout_width="match_parent" android:layout_height="wrap_content"> <linearlayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:orientation="vertical" > <button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical" > android:layout_weight="1" <button android:id="@+id/button2" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:orientation="vertical" > <button android:id="@+id/button3" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> </linearlayout>

android dialog android-linearlayout

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -