gpt4 book ai didi

java - BottomSheetDialog 在 Android 中没有正确地圆顶角

转载 作者:行者123 更新时间:2023-12-05 00:14:40 26 4
gpt4 key购买 nike

我有一个自定义的 BottomSheetDialog 并且我为其布局创建了具有顶角圆角矩形的可绘制对象。 BottomSheetDialog 布局背景是一个 Linearlayout 并且我将 drawable 应用于布局。底部工作表的顶角正确四舍五入但是线性布局的另一个布局底部不是圆形(方形和白色见下图)并且它不在 layout.xml 文件中。它就像正方形顶部的圆角矩形。我无法摆脱那个正方形。

enter image description here

下面是我的自定义底页示例

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);
}
}

下面是我的风格

 <style name="BottomSheetDialogStyle" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowSoftInputMode">adjustResize</item>
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay</item>
<item name="backgroundTint">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
</style>

下面是我的底页layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/transparent"
app:layout_behavior="@string/bottom_sheet_behavior">

<LinearLayout
android:id="@+id/dialog_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bottom_sheet_background"
android:padding="10dp">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_arrow_drop_down_24" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/between_two_views">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/search_wrapper"
style="@style/textInputHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_employees">

<EditText
android:id="@+id/search"
style="@style/textInputText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

<ImageButton
android:id="@+id/close_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:background="@null"
android:src="@drawable/ic_baseline_close_24"
android:text="Button" />

</RelativeLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/employee_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/between_two_views"/>

</LinearLayout>

</LinearLayout>

下面是我画的圆角

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="20dp" android:topRightRadius="20dp"/>
<solid android:color="@color/red" />
</shape>

最佳答案

要解决这个问题,您需要在对话框样式(BottomSheetDialog 样式)中使用透明背景色:

<item name="android:colorBackground">@android:color/transparent</item>

关于java - BottomSheetDialog 在 Android 中没有正确地圆顶角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70397223/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com