gpt4 book ai didi

android - ShapeableImageView 不圆角

转载 作者:行者123 更新时间:2023-12-05 00:15:28 25 4
gpt4 key购买 nike

ShapeableImageView 采用样式中的 ShapeAppearanceOverlay 项来创建所需的形状和大小。形状族被切割和圆形,半径可以用作数字或百分比。
这是我的圆形 ImageView 的 ShapeAppearanceOverlay 主题:

<style name="ShapeAppearanceOverlay.App.circleImageView" parent="">
<item name="cornerFamily">cut</item>
<item name="cornerSize">50%</item>
</style>
这是我使用它的布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="240dp" />
<!--Top Header Layout-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/topbar"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--Top Profile Section -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/user_display_image"
style="@style/ShapeAppearanceOverlay.App.circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/ic_user" />
</LinearLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/normal_bottom_margin" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
这是该问题的屏幕截图:
enter image description here
IDE截图:
enter image description here

最佳答案

使用 app:shapeAppearanceOverlay 而不是 style

<com.google.android.material.imageview.ShapeableImageView
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.circleImageView"
.../>

关于android - ShapeableImageView 不圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66624415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com