How to use Android Puzzle Style dialog box buttons

I am creating a Holo Theme dialog box and want to follow the standard methods for displaying buttons on the OS. So far I have created a dialog box, but the buttons do not appear as is done in applications run in Holo for ICS. How can i do this? My intended appearance No. 3rd in this image and i can get here Notice the Signup and Login buttons

+52
android android-theme
Mar 21 2018-12-12T00:
source share
3 answers

a little late, but maybe someone is still interested in this.

It works very well for me.

... <!-- EDIT: be carefull, "?android:attr/dividerHorizontal" is only supported since API 11 just avoid it in prior OSs. --> <View android:layout_width="fill_parent" android:layout_height="1dip" android:background="?android:attr/dividerHorizontal" /> <LinearLayout style="?android:attr/buttonBarStyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingTop="0dip" android:paddingLeft="2dip" android:paddingRight="2dip" android:measureWithLargestChild="true"> <Button android:id="@+id/cancel" style="?android:attr/buttonBarButtonStyle" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="@android:string/cancel"/> <Button android:id="@+id/ok" style="?android:attr/buttonBarButtonStyle" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="@android:string/ok"/> </LinearLayout> ... 

the activity that loads this layout requires the Holo.Dialog theme.

 android:theme="@android:style/Theme.Holo.Dialog" 
+85
Jul 23 2018-12-23T00:
source share

This is what works:

 <LinearLayout android:id="@+id/buttonHolder" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/cmdSignup" style="@android:style/Widget.Holo.Light.Button.Borderless.Small" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/Signup" /> <Button android:id="@+id/cmdLogin" style="@android:style/Widget.Holo.Light.Button.Borderless.Small" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/Login" /> </LinearLayout> 

The style="@android:style/Widget.Holo.Light.Button.Borderless.Small" gives a flat look and 50% weight distribution due to the combination of $ 100 LinearLayout on android:layout_width="match_parent" and android: layout_weight = "1" `for buttons

+22
Mar 21 2018-12-21T00:
source share

You can install the theme through Android Manifest xml or inside Activity onCreate using setTheme(android.R.style.Theme_Holo);

The size of the buttons is not related to the theme itself. Size depends on your xml definitions. In the image you posted, the buttons seem to have got the Holo theme, so there’s nothing wrong ...

Here's an xml layout that stretches the buttons to fill the entire width of the dialog box:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" > <Button android:id="@+id/okButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="OK" /> <Button android:id="@+id/cancelButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LinearLayout> </LinearLayout> 
+2
Mar 21 2018-12-12T00:
source share



All Articles