2017-08-29 92 views
1

enter image description here enter image description here 我在彈出的問題,我的彈出對話框顯示非結構化的,我想是這樣,我在這裏附上了我的Android XML too.why我的流行音樂太small.Here是我的代碼我在填充父應用線性佈局這是一個問題?彈出對話框問題的Android

<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> 

+0

您可以通過向佈局的元素添加邊距或填充以使UI像您想要的那樣進行一些調整。 – sasuke

+0

請通過這個[網站](http://guides.codepath.com/android/Using-DialogFragment) – Basi

回答

1

試試這個設置HIGHT和你對話的寬度編程方式使用Window像下面的代碼

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

,並添加一些android:layout_marginpadding在LinearLayout中這樣

<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"> 
0

最簡單的方法就是我們在您的父級佈局中使用android:layout_marginandroid:padding。您可以使用這樣的事情:

<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> 
0

添加一定的餘量,以您的佈局:

<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> 
0

你可以嘗試這樣的。它將設置爲所有屏幕尺寸。

<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>