为底部抽屉扩展部分设置圆角?

huangapple go评论74阅读模式
英文:

Round corners for BottomSheet expanded?

问题

以下是您要翻译的内容:

"Out of curiosity, what needs to be done that the damn bottom sheet actually keeps its rounded corners in expanded state?

Im struggling the whole day with that issue, i have a bottomsheet defined in XML, material design 1.9 and it still flattens them. Are there any files that require a replacement?

Depends...

dependencies {

    implementation project(':unityLibrary')
    implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])

    implementation 'androidx.core:core-ktx:1.10.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.squareup.picasso:picasso:2.8'
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation("com.android.volley:volley:1.2.1")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")    // Kotlin

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

            <androidx.coordinatorlayout.widget.CoordinatorLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.6">

                <FrameLayout
                    android:id="@+id/standard_bottom_sheet"
                    style="@style/Widget.Material3.BetterBottomSheet"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:behavior_hideable="false"
                    app:behavior_peekHeight="32dp"
                    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
...
<style name="Widget.Material3.BetterBottomSheet" parent="Widget.Material3.BottomSheet">
        <item name="android:elevation">@dimen/m3_bottom_sheet_elevation</item>
        <item name="marginLeftSystemWindowInsets">true</item>
        <item name="marginRightSystemWindowInsets">true</item>
        <item name="paddingBottomSystemWindowInsets">true</item>
        <item name="paddingTopSystemWindowInsets">true</item>
        <item name="paddingLeftSystemWindowInsets">false</item>
        <item name="paddingRightSystemWindowInsets">false</item>
        <item name="shapeAppearance">@macro/m3_comp_sheet_bottom_docked_container_shape</item>
        <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.Corner.Top</item>
        <item name="shouldRemoveExpandedCorners">false</item>  // True also does not work
        <item name="backgroundTint">@macro/m3_comp_sheet_bottom_docked_container_color</item>
    </style>

What am i doing wrong here? Is there a way to make a BottomSheet keep its round corners once expanded?"

英文:

Out of curiosity, what needs to be done that the damn bottom sheet actually keeps its rounded corners in expanded state?

Im struggling the whole day with that issue, i have a bottomsheet defined in XML, material design 1.9 and it still flattens them. Are there any files that require a replacement?

Depends...

dependencies {

    implementation project(&#39;:unityLibrary&#39;)
    implementation fileTree(dir: project(&#39;:unityLibrary&#39;).getProjectDir().toString() + (&#39;\\libs&#39;), include: [&#39;*.jar&#39;])

    implementation &#39;androidx.core:core-ktx:1.10.0&#39;
    implementation &#39;androidx.appcompat:appcompat:1.6.1&#39;
    implementation &#39;com.google.android.material:material:1.9.0&#39;
    implementation &#39;androidx.constraintlayout:constraintlayout:2.1.4&#39;
    implementation &#39;com.squareup.picasso:picasso:2.8&#39;
    implementation &#39;com.google.code.gson:gson:2.10.1&#39;
    implementation(&quot;com.android.volley:volley:1.2.1&quot;)
    implementation(&quot;org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0&quot;)    // Kotlin

    testImplementation &#39;junit:junit:4.13.2&#39;
    androidTestImplementation &#39;androidx.test.ext:junit:1.1.5&#39;
    androidTestImplementation &#39;androidx.test.espresso:espresso-core:3.5.1&#39;
}

            &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;0dp&quot;
                android:layout_weight=&quot;0.6&quot;&gt;

                &lt;FrameLayout
                    android:id=&quot;@+id/standard_bottom_sheet&quot;
                    style=&quot;@style/Widget.Material3.BetterBottomSheet&quot;
                    android:layout_width=&quot;match_parent&quot;
                    android:layout_height=&quot;match_parent&quot;
                    app:behavior_hideable=&quot;false&quot;
                    app:behavior_peekHeight=&quot;32dp&quot;
                    app:layout_behavior=&quot;com.google.android.material.bottomsheet.BottomSheetBehavior&quot;&gt;
...
&lt;style name=&quot;Widget.Material3.BetterBottomSheet&quot; parent=&quot;Widget.Material3.BottomSheet&quot;&gt;
        &lt;item name=&quot;android:elevation&quot;&gt;@dimen/m3_bottom_sheet_elevation&lt;/item&gt;
        &lt;item name=&quot;marginLeftSystemWindowInsets&quot;&gt;true&lt;/item&gt;
        &lt;item name=&quot;marginRightSystemWindowInsets&quot;&gt;true&lt;/item&gt;
        &lt;item name=&quot;paddingBottomSystemWindowInsets&quot;&gt;true&lt;/item&gt;
        &lt;item name=&quot;paddingTopSystemWindowInsets&quot;&gt;true&lt;/item&gt;
        &lt;item name=&quot;paddingLeftSystemWindowInsets&quot;&gt;false&lt;/item&gt;
        &lt;item name=&quot;paddingRightSystemWindowInsets&quot;&gt;false&lt;/item&gt;
        &lt;item name=&quot;shapeAppearance&quot;&gt;@macro/m3_comp_sheet_bottom_docked_container_shape&lt;/item&gt;
        &lt;item name=&quot;shapeAppearanceOverlay&quot;&gt;@style/ShapeAppearanceOverlay.Material3.Corner.Top&lt;/item&gt;
        &lt;item name=&quot;shouldRemoveExpandedCorners&quot;&gt;false&lt;/item&gt;  // True also does not work
        &lt;item name=&quot;backgroundTint&quot;&gt;@macro/m3_comp_sheet_bottom_docked_container_color&lt;/item&gt;
    &lt;/style&gt;

What am i doing wrong here? Is there a way to make a BottomSheet keep its round corners once expanded?

答案1

得分: 1

底部表单不能有底部圆角。这在开发者方面引起了很大的争议。圆角表明有可滚动的文本,因此他们只允许顶部是圆角的。

参见此链接:https://github.com/material-components/material-components-android/pull/437#issuecomment-536668983

因此,除非他们决定让我们覆盖该方法,否则我们将永远只能使用顶部圆角。

英文:

The bottom sheet can not have bottom corners. This was a big debate on the developers side. The rounded corners indicated that there was scrollable text. So they only allow for the top to be rounded.

See this: https://github.com/material-components/material-components-android/pull/437#issuecomment-536668983

So we are forever stuck with only top round corners unless they decide to let us override the method.

huangapple
  • 本文由 发表于 2023年5月11日 08:01:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76223296.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定