0
不完全在右側我試圖將我的DialogFragment
完全放在手機的右側。奇怪的是,它以前工作過,但我不知道我到底做了什麼,但我知道這是可能的。DialogFragment與Gravity.Right
正如您在圖片中看到的那樣,DialogFragment
和屏幕右側之間有一點空間。我根本不想要那個空間。片段必須完全位於右側。
我DialogFragment類:
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();
}
}
爲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>
也許這個回答可以幫助你:http://stackoverflow.com/questions/18536439/dialogfragment-fullscreen-shows-padding-on-sides –
@FrancisStraccia感謝的人!它幫助! – Muddz