ISH*_*IYA 3 java android android-bottomsheetdialog
我有一个自定义的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)
下面是我的风格
<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>
Run Code Online (Sandbox Code Playgroud)
下面是我的底表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>
Run Code Online (Sandbox Code Playgroud)
下面是我的圆角绘图
<?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>
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,您需要在对话框样式(BottomSheetDialogStyle)中使用透明背景色:
<item name="android:colorBackground">@android:color/transparent</item>
Run Code Online (Sandbox Code Playgroud)