我想在另一个活动之上创建一个透明的Activity.
我怎样才能做到这一点?
如何删除底部工作表对话框片段中的白色背景?
我试图在回答这个或设置在布局XML透明背景,但仍得到这样的结果
这是我的代码
public class BottomSheetFragment extends BottomSheetDialogFragment {
private Record record;
private MainFragment fragment;
public static BottomSheetFragment getInstance() {
return new BottomSheetFragment ();
}
public BottomSheetFragment setRecord(Record record) {
this.record = record;
return this;
}
public BottomSheetFragment setFragment(MainFragment fragment) {
this.fragment = fragment;
return this;
}
@TargetApi(Build.VERSION_CODES.O)
@Override
public void onViewCreated(View view, @Nullable final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT);
setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
//Set content
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable …Run Code Online (Sandbox Code Playgroud) 我使用 BottomSheetDialog,出现了一些困难。我想删除黑色背景的背景,并将其更改为透明。我尝试了这个带有透明背景的 BottomSheetDialog,但没有成功。帮我。
[在此输入图像描述][1]
代码是:
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity());
View parentView = getLayoutInflater().inflate(R.layout.content_status_dialog,null);
bottomSheetDialog.setContentView(parentView);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View)parentView.getParent());
bottomSheetDialog.setCancelable(true);
bottomSheetBehavior.setPeekHeight((int)TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,100,
getResources().getDisplayMetrics()));
bottomSheetDialog.show();
Run Code Online (Sandbox Code Playgroud)
如果我添加一些像这样的样式
((View) getView().getParent()).setBackgroundColor(Color.TRANSPARENT);
Run Code Online (Sandbox Code Playgroud)
,它看起来像这样
我有一个自定义的BottomSheetDialog布局,我创建了可绘制的布局,它具有顶角圆角矩形。BottomSheetDialog布局背景是 a Linearlayout,我将可绘制对象应用于布局。底部工作表的顶角正确舍入,但线性布局的另一个布局底部不是圆角的(方形和白色见下图),并且它不在布局中.xml 文件。它就像正方形顶部的圆角矩形。我无法摆脱那个正方形。
以下是我的定制底板样本
public abstract class EmployeeBottomSheetDialog extends BottomSheetDialog {
private Context context;
private Activity activity;
private RecyclerView employeeRecyclerView;
private EditText searchEditText;
private DataBase dataBase;
private ArrayList<Employe> employeeList = new ArrayList<>();
private ArrayList<Employe> employeeSelectedList = new ArrayList<>();
private SelectEmployeeAdapter selectEmployeeAdapter;
private ImageButton closeSearchImageButton;
public EmployeeBottomSheetDialog(@NonNull Context context, List<Employe> selectedEmployeeList) {
super(context,R.style.BottomSheetDialogStyle);
this.context = context;
this.activity = (Activity) context;
if(!selectedEmployeeList.isEmpty()){
employeeSelectedList.clear();
employeeSelectedList.addAll(selectedEmployeeList);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.employee_bottom_sheet_dialog);
}
} …Run Code Online (Sandbox Code Playgroud)