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

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

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...

  1. dependencies {
  2. implementation project(':unityLibrary')
  3. implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
  4. implementation 'androidx.core:core-ktx:1.10.0'
  5. implementation 'androidx.appcompat:appcompat:1.6.1'
  6. implementation 'com.google.android.material:material:1.9.0'
  7. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  8. implementation 'com.squareup.picasso:picasso:2.8'
  9. implementation 'com.google.code.gson:gson:2.10.1'
  10. implementation("com.android.volley:volley:1.2.1")
  11. implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") // Kotlin
  12. testImplementation 'junit:junit:4.13.2'
  13. androidTestImplementation 'androidx.test.ext:junit:1.1.5'
  14. androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
  15. }
  1. <androidx.coordinatorlayout.widget.CoordinatorLayout
  2. android:layout_width="match_parent"
  3. android:layout_height="0dp"
  4. android:layout_weight="0.6">
  5. <FrameLayout
  6. android:id="@+id/standard_bottom_sheet"
  7. style="@style/Widget.Material3.BetterBottomSheet"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. app:behavior_hideable="false"
  11. app:behavior_peekHeight="32dp"
  12. app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
  13. ...
  1. <style name="Widget.Material3.BetterBottomSheet" parent="Widget.Material3.BottomSheet">
  2. <item name="android:elevation">@dimen/m3_bottom_sheet_elevation</item>
  3. <item name="marginLeftSystemWindowInsets">true</item>
  4. <item name="marginRightSystemWindowInsets">true</item>
  5. <item name="paddingBottomSystemWindowInsets">true</item>
  6. <item name="paddingTopSystemWindowInsets">true</item>
  7. <item name="paddingLeftSystemWindowInsets">false</item>
  8. <item name="paddingRightSystemWindowInsets">false</item>
  9. <item name="shapeAppearance">@macro/m3_comp_sheet_bottom_docked_container_shape</item>
  10. <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.Corner.Top</item>
  11. <item name="shouldRemoveExpandedCorners">false</item> // True also does not work
  12. <item name="backgroundTint">@macro/m3_comp_sheet_bottom_docked_container_color</item>
  13. </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...

  1. dependencies {
  2. implementation project(&#39;:unityLibrary&#39;)
  3. implementation fileTree(dir: project(&#39;:unityLibrary&#39;).getProjectDir().toString() + (&#39;\\libs&#39;), include: [&#39;*.jar&#39;])
  4. implementation &#39;androidx.core:core-ktx:1.10.0&#39;
  5. implementation &#39;androidx.appcompat:appcompat:1.6.1&#39;
  6. implementation &#39;com.google.android.material:material:1.9.0&#39;
  7. implementation &#39;androidx.constraintlayout:constraintlayout:2.1.4&#39;
  8. implementation &#39;com.squareup.picasso:picasso:2.8&#39;
  9. implementation &#39;com.google.code.gson:gson:2.10.1&#39;
  10. implementation(&quot;com.android.volley:volley:1.2.1&quot;)
  11. implementation(&quot;org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0&quot;) // Kotlin
  12. testImplementation &#39;junit:junit:4.13.2&#39;
  13. androidTestImplementation &#39;androidx.test.ext:junit:1.1.5&#39;
  14. androidTestImplementation &#39;androidx.test.espresso:espresso-core:3.5.1&#39;
  15. }
  1. &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
  2. android:layout_width=&quot;match_parent&quot;
  3. android:layout_height=&quot;0dp&quot;
  4. android:layout_weight=&quot;0.6&quot;&gt;
  5. &lt;FrameLayout
  6. android:id=&quot;@+id/standard_bottom_sheet&quot;
  7. style=&quot;@style/Widget.Material3.BetterBottomSheet&quot;
  8. android:layout_width=&quot;match_parent&quot;
  9. android:layout_height=&quot;match_parent&quot;
  10. app:behavior_hideable=&quot;false&quot;
  11. app:behavior_peekHeight=&quot;32dp&quot;
  12. app:layout_behavior=&quot;com.google.android.material.bottomsheet.BottomSheetBehavior&quot;&gt;
  13. ...
  1. &lt;style name=&quot;Widget.Material3.BetterBottomSheet&quot; parent=&quot;Widget.Material3.BottomSheet&quot;&gt;
  2. &lt;item name=&quot;android:elevation&quot;&gt;@dimen/m3_bottom_sheet_elevation&lt;/item&gt;
  3. &lt;item name=&quot;marginLeftSystemWindowInsets&quot;&gt;true&lt;/item&gt;
  4. &lt;item name=&quot;marginRightSystemWindowInsets&quot;&gt;true&lt;/item&gt;
  5. &lt;item name=&quot;paddingBottomSystemWindowInsets&quot;&gt;true&lt;/item&gt;
  6. &lt;item name=&quot;paddingTopSystemWindowInsets&quot;&gt;true&lt;/item&gt;
  7. &lt;item name=&quot;paddingLeftSystemWindowInsets&quot;&gt;false&lt;/item&gt;
  8. &lt;item name=&quot;paddingRightSystemWindowInsets&quot;&gt;false&lt;/item&gt;
  9. &lt;item name=&quot;shapeAppearance&quot;&gt;@macro/m3_comp_sheet_bottom_docked_container_shape&lt;/item&gt;
  10. &lt;item name=&quot;shapeAppearanceOverlay&quot;&gt;@style/ShapeAppearanceOverlay.Material3.Corner.Top&lt;/item&gt;
  11. &lt;item name=&quot;shouldRemoveExpandedCorners&quot;&gt;false&lt;/item&gt; // True also does not work
  12. &lt;item name=&quot;backgroundTint&quot;&gt;@macro/m3_comp_sheet_bottom_docked_container_color&lt;/item&gt;
  13. &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:

确定