I need to launch a Dialog from home screen widget, so I created an Activity with android:theme="@android:style/Theme.Dialog"
The problem is, that I would like make it look like standard dialog window ( buttons on the gray background, font and text size, paddings etc), like here:
(source: android.com) 开发者_JAVA技巧This is how my "dialog" Activity looks like:
Is there some standard way (theme?) to make it look like standard system dialogs? Or do I have to imitate it in my own layout?
You can get the same look for the buttons below by using the weight attribute and the framework drawable for the background behind them. Hope this helps!
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/bottom_bar"
android:orientation="horizontal">
<Button
android:text="Cancel"
android:textSize="12dip"
android:id="@+id/cancelButton"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="5dip"/>
<Button
android:text="Ok"
android:textSize="12dip"
android:id="@+id/okButton"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="5dip"/>
</LinearLayout>
The top dialog is built using the AlertDialog.Builder, to create a simple dialog you should use that class.
精彩评论