英文:
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(':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?
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论