【问题标题】:Android Custom Dialog Size [duplicate]Android自定义对话框大小[重复]
【发布时间】:2017-12-28 10:04:04
【问题描述】:

我有一个自定义对话框,xml代码如下,但是对话框打开时视图很小,如何自定义它的大小

<LinearLayout
    android:orientation="vertical"
    android:background="#ffffff"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Spinner
        android:id="@+id/name_list"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </Spinner>
    <Button
        android:id="@+id/name_search"
        android:text="Search"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:background="#ffffff"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

【问题讨论】:

    标签: android dialog


    【解决方案1】:

    试试这个

    自定义对话框集 heightwidth 以编程方式使用 Window

    Window window = customDialog.getWindow();
    window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
    window.setGravity(Gravity.CENTER);
    customDialog.show();
    

    【讨论】:

    • 谢谢你的大师它的工作
    • @KarthickRamanathan 很高兴为您提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    • 1970-01-01
    相关资源
    最近更新 更多