相关疑难解决方法(0)

如何在Android上创建透明活动?

我想在另一个活动之上创建一个透明的Activity.

我怎样才能做到这一点?

android transparent android-activity

881
推荐指数
15
解决办法
42万
查看次数

删除底部工作表对话框片段中的白色背景

如何删除底部工作表对话框片段中的白色背景?

我试图在回答这个或设置在布局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)

android

6
推荐指数
2
解决办法
8361
查看次数

如何更改BottomSheetDialog中的透明背景?

我使用 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)

,它看起来像这样

android

3
推荐指数
1
解决办法
9435
查看次数

BottomSheetDialog 在 Android 中未正确圆化顶角

我有一个自定义的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)

java android android-bottomsheetdialog

3
推荐指数
1
解决办法
4714
查看次数