1

I'm trying to place my DialogFragment completely to right side of the phone. Strangely it worked before, but I don't know what I exactly I did, but I know it's possible.

As you can see on the picture there is a little amount of space between the DialogFragment and the right side of the screen. I don't want that space at all. The fragment has to be completely on the right side.

enter image description here

My DialogFragment class:

public class FontFragment extends DialogFragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fontmenu, container);
    recyclerView = (RecyclerView) v.findViewById(R.id.fontmenuRcv);

    recyclerView.setHasFixedSize(true);

    FontMenuAdapter fontsAdapter = new FontMenuAdapter(Font.initFonts(getContext()), editText, getContext(), editText.getSelectionStart(), editText.getSelectionEnd(), this);
    recyclerView.setAdapter(fontsAdapter);

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);

    return v;
}

@Override
public void onResume() {

    getDialog().getWindow().setGravity(Gravity.RIGHT|Gravity.BOTTOM);

    super.onResume();

  }
}

The layout for the dialogfragment:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fontmenuRcv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">

</android.support.v7.widget.RecyclerView>
manfcas
  • 1,933
  • 7
  • 28
  • 47

1 Answers1

1

I fixed my problem with this simple solution from the accepted answer: https://stackoverflow.com/a/18554868/5366495

 <style name="CustomDialog" parent="Theme.AppCompat.Light.NoActionBar" >
    <item name="android:windowBackground">@color/white</item>
    <item name="android:windowIsFloating">true</item>
 </style>
Community
  • 1
  • 1