简体   繁体   English

Android中弹出对话框的问题

[英]Pop up dialog issue in android

在此处输入图片说明 在此处输入图片说明 I have an issue in popup,my popup dialog is showing unstructured,i wanna like this,here i attached my android XML too.why my pop is too small.Here is my code i applied linear layout in fill parent this is an issue?? 我在弹出窗口中遇到问题,我的弹出对话框显示为非结构化,我想这样,在这里我也附加了我的android XML。为什么我的弹出窗口太小。这是我在线性填充中应用代码的父代码,这是一个问题吗? ?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Video Download Quality"
        android:textColor="@color/colorPrimaryBlack"
        android:textSize="20dp" />

    <RadioGroup
        android:id="@+id/radio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">
        <RadioButton
            android:id="@+id/radiofrst"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="360dp" />
        <RadioButton
            android:id="@+id/radiosecond"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="480dp" />

        <RadioButton
            android:id="@+id/radiothird"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="720dp" />
        <RadioButton
            android:id="@+id/radioforuth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1080dp" />
    </RadioGroup>
</LinearLayout>

try this set hight and width of your dialog programatically using Window like below code 像下面的代码一样使用Window尝试以编程方式设置对话框的高度和宽度

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

and add some android:layout_margin or padding in LinearLayout like this 然后像这样在LinearLayout中添加一些android:layout_marginpadding

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_margin="10dp"
 android:layout_gravity="center"
 android:orientation="vertical">

The easiest way is using an android:layout_margin or android:padding in your parent layout. 最简单的方法是在父级布局中使用android:layout_marginandroid:padding You can use something like this: 您可以使用如下形式:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="15dp"
    android:layout_gravity="center"
    android:orientation="vertical">

  ...

</LinearLayout>

Add some margin to your layout: 为您的布局添加一些边距:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Video Download Quality"
        android:textColor="@color/colorPrimaryBlack"
        android:textSize="20dp" />

    <RadioGroup
        android:id="@+id/radio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp">
        <RadioButton
            android:id="@+id/radiofrst"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="360dp" />
        <RadioButton
            android:id="@+id/radiosecond"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="480dp" />

        <RadioButton
            android:id="@+id/radiothird"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="720dp" />
        <RadioButton
            android:id="@+id/radioforuth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1080dp" />
    </RadioGroup>
</LinearLayout>

You can try like this. 您可以这样尝试。 It will set in all screen size. 它将以所有屏幕尺寸进行设置。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="#50000000"
    android:gravity="center">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:background="@color/colorWhite"
        android:orientation="vertical"
        android:padding="15dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Video Download Quality"
            android:textSize="20dp" />

        <RadioGroup
            android:id="@+id/radio"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp">

            <RadioButton
                android:id="@+id/radiofrst"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="360dp" />

            <RadioButton
                android:id="@+id/radiosecond"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="480dp" />

            <RadioButton
                android:id="@+id/radiothird"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="720dp" />

            <RadioButton
                android:id="@+id/radioforuth"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1080dp" />
        </RadioGroup>
    </LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM