Android 为图像添加圆角
如何在图像中添加圆角和一点阴影,使其看起来像附件 以下是我在活动中的内容Android 为图像添加圆角,android,kotlin,Android,Kotlin,如何在图像中添加圆角和一点阴影,使其看起来像附件 以下是我在活动中的内容 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <!-- Content here --> <Image
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Content here -->
<ImageView
android:id="@+id/imageView1"
android:layout_width="107dp"
android:layout_height="166dp"
android:layout_marginStart="20dp"
android:elevation="5dp"
android:scaleType="fitCenter"
android:translationZ="12dp"
android:layout_marginTop="15dp" />
你可以用现成的东西 或者定制背景
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- View background color -->
<solid
android:color="@color/colorPrimary" >
</solid>
<!-- The radius makes the corners rounded -->
<corners
android:radius="8dp" >
</corners>
</shape>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle"/>
可以更改“角点半径”标记
然后将其标记为背景
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- View background color -->
<solid
android:color="@color/colorPrimary" >
</solid>
<!-- The radius makes the corners rounded -->
<corners
android:radius="8dp" >
</corners>
</shape>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle"/>
您有不同的选择
- 您可以使用
作为根布局cardwiew
- 您可以使用
材质形状可移动的
()
- 从的
版本开始,您可以将1.2.0-alpha03
更改为新的ImageView
ShapeableImageView
<com.google.android.material.imageview.ShapeableImageView
...
app:shapeAppearanceOverlay="@style/roundedImageView"
app:srcCompat="@drawable/ic_custom_image" />
这是否回答了您的问题?使用
cardwiew
作为根布局。。