問題描述
當(dāng)我在布局中使用時,它指定了這個對話框 android:layout_width="match_parent"
我得到了這個對話框:
When I use in layout, which specifies this dialog android:layout_width="match_parent"
I get this dialog:
我需要更寬的對話框.有什么想法嗎?
I need dialog which will be wider. Any ideas?
推薦答案
您可以通過抓取對話框使用的 Window
對象并重置寬度來實現(xiàn).這是一個簡單的例子:
You can do that by grabbing the Window
object that the dialog uses, and resetting the width. Here's a simple example:
這是最終結(jié)果.請注意,如果您需要微調(diào)某些內(nèi)容(例如更改背景等),您可以對對話框進行更多樣式設(shè)置.當(dāng)我過去不得不這樣做時,我通常使用這種方法,并在構(gòu)建器類上使用 setView()
自定義對話框中使用的布局.
Here's the end result. Note that there's a lot more styling you can do to the dialog if you need to fine tune things (like change the background, etc). When I've had to do this in the past, I usually use this method, and customize the layout used in the dialog with setView()
on the builder class.
這篇關(guān)于如何創(chuàng)建將在水平維度上充滿的對話框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!