开发者

Tunning up Activity with dialog theme

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:

Tunning up Activity with dialog theme

(source: android.com)

开发者_JAVA技巧

This is how my "dialog" Activity looks like:

Tunning up Activity with dialog theme

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜