在我的BottomSheetDialogFragment中,我有一个按钮,我想让这个按钮的背景成为圆角矩形,并有一条灰色边框。
这是我的圆角背景drawable "rounded_tranparent_background.xml":
应用了所有的代码后,我仍然无法获得我想要的设计。 我想要的设计是:,而我现在得到的是。如何才能在底部弹窗对话框中实现自定义按钮设计?
这是我的圆角背景drawable "rounded_tranparent_background.xml":
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<solid android:color="#FFF" />
<stroke
android:width="1dp"
android:color="#8A8383" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
我将这个背景应用到了我的底部面板按钮中。
这是底部面板的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnFollowUnfollow"
android:background="@drawable/rounded_tranparent_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/avenir_next_ltpro_medium"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Unfollow"
android:textColor="@color/colorGreyDark"
app:layout_constraintBaseline_toBaselineOf="@+id/tvTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.71"
app:layout_constraintStart_toEndOf="@+id/tvTitle" />
//...other code...
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
这是我底部对话框的样式
<style name="AppBottomSheetDialogTheme"
parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:windowTranslucentStatus">true</item>
<item name="colorPrimary">@color/colorBlue</item>
<item name="colorPrimaryDark">@color/colorBlueDark</item>
<item name="colorAccent">@android:color/transparent</item>
</style>
应用了所有的代码后,我仍然无法获得我想要的设计。 我想要的设计是:,而我现在得到的是。如何才能在底部弹窗对话框中实现自定义按钮设计?