问题
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
回答1:
With the Material Components library you can use the 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
.
回答2:
You can try to create a rounded bitmap with Glide or Picasso. In this case you can write transformation. See, for instance, Make ImageView with Round Corner Using picasso.
Then you can create an image with a shadow. After that overlap one image over another.
回答3:
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
<?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
来源:https://stackoverflow.com/questions/60172467/how-to-make-image-view-with-three-corner-and-shadow