1

私のBottomSheetDialogFragmentにはボタンがあります。このボタンの背景を灰色の境界線で丸くしたいと思います。

これが私の丸みを帯びた背景ドローアブル「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>

このコードをすべて適用した後、探しているものを達成できませんでした。希望するデザインは次のとおりです。探しているボタンのデザイン

そして私が得ているもの私が今得ているボタンのデザイン

ボトムシートダイアログのボタンでカスタムデザインを実現するにはどうすればよいですか?

4

3 に答える 3

4

シンプルなものを使用できますMaterialButton

        <com.google.android.material.button.MaterialButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:cornerRadius="10dp"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:textColor="..."
            app:strokeColor="..."/>

ここに画像の説明を入力

于 2020-08-16T16:54:18.110 に答える