1

I am trying to create an Internet connectivity error dialog box. I have the dialogFragment code for it, which inflates a layout. The problem is, the layout appears fine in the android studio, but on the phone, it appears with an extra horizontal strip on the top.The snapshot of the dialog box on the phone

The snap of the dialog box in Android Studio

This is the layout code :

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="@style/Animation.AppCompat.Dialog">


<TextView
    android:text="TextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:layout_weight="1" />

<RadioButton
    android:text="RadioButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/radioButton"
    android:layout_weight="1" />
</LinearLayout>

Can anyone please help me understand why I am getting this extra strip. I tried putting CardView and other layouts instead of LinearLayout, but the strip seems to be something beyond the layout file. I cannot access or modify it.

Rajan Prasad
  • 1,582
  • 1
  • 16
  • 33

1 Answers1

1

DialogFragment has a default divider on top. You can remove the divider with following code -

int dividerID = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", "id", "android"); View divider = dialog.findViewById(dividerID); You can then set height to 0 or transparent color to the view.

Harsh
  • 599
  • 3
  • 20