[英]how to make image view with three corner and shadow
How to make an image with only three corners like this I tried using frame layout the insert image view and make it's resource with original image the add another image view with src of border that has 3 corner bu it doesn't work如何制作只有三个角的图像,我尝试使用框架布局插入图像视图,并使其成为原始图像的资源,添加另一个具有 3 个角的边框 src 的图像视图,但它不起作用
With the Material Components library you can use the MaterialShapeDrawable
.通过Material Components 库,您可以使用
MaterialShapeDrawable
。
Just use something like:只需使用类似的东西:
<com.google.android.material.imageview.ShapeableImageView
app:shapeAppearanceOverlay="@style/onlyonecorner"
app:srcCompat="@drawable/xxx"
../>
with:和:
<style name="onlyonecorner">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
<item name="cornerSizeTopRight">0dp</item>
</style>
The ShapeableImageView
requires a minimum of version 1.2.0-alpha03
. ShapeableImageView
至少需要1.2.0-alpha03
版本。
You can try to create a rounded bitmap with Glide or Picasso.您可以尝试使用 Glide 或 Picasso 创建圆形位图。 In this case you can write transformation.
在这种情况下,您可以编写转换。 See, for instance, Make ImageView with Round Corner Using picasso .
例如, 请参阅使用 picasso 制作带有圆角的 ImageView 。
Then you can create an image with a shadow.然后,您可以创建带有阴影的图像。 After that overlap one image over another.
之后,将一张图像重叠在另一张图像上。
You can use something like this:你可以使用这样的东西:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#587E9B">
<Button
android:id="@+id/button5"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintDimensionRatio="1:1"
android:text="Button"
android:background="@drawable/my_shape"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
drawable/my_shape可绘制/my_shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="12dp" />
<solid android:color="#CF2525" />
<corners
android:topLeftRadius="60dp"
android:bottomRightRadius="60dp"
android:bottomLeftRadius="60dp"/>
<stroke
android:width="1dp"
android:color="@android:color/black" />
</shape>
Here is how it will look:这是它的外观:
Now all you need to do is to change the corners
inside drawable/my_shape
现在你需要做的就是改变
drawable/my_shape
里面的corners
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.