我尝试向我的 BottomSheetDialogFragment 添加边距,但它对边距没有任何作用。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="16dp">
<TextView
android:id="@+id/alertdialog_fragmail_newmessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test 1"
android:textStyle="bold"
android:padding="16dp"
android:textColor="@color/colorBlackFont"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:drawablePadding="16dp"/>
//More Textviews
</RelativeLayout>
编辑:_________________________________________________________________
我已经尝试将 XML 更改为下面的答案,但是它仍然没有为我的 bottomsheetdialogfragment 创建边距。
底部工作表对话框片段类的代码:
public class FragMailMoreDialog extends BottomSheetDialogFragment {
private static final String TAG = "FragMailMoreDialog";
private Context mContext;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getContext();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.alertdialog_layout_fragmailmore, container, false);
ButterKnife.bind(this, view);
return view;
}
}
充气底片的代码:
private void inflateMoreDialog(){
FragMailMoreDialog moreDialog = new FragMailMoreDialog();
if (getFragmentManager() != null) {
moreDialog.show(getFragmentManager(), "FRAGMAIL_MORE_DIALOG");
}
}