これが私が達成した方法です。drawable を使用inset
すると、これを簡単に実現でき、より少ないコードでより多くのカスタマイズを行うことができます。これを使ってtwoside_border.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- inset: It can remove border from any other side-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetBottom="-15dp"
android:insetRight="-15dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rectangle">
<stroke
android:width="20dp"
android:color="#ED302F" />
<!--<corners
android:topLeftRadius="20dp"
/>-->
<!--<solid android:color="#f50a0a" />-->
</shape>
insetBottom
& insetRight
-dp値は、必要のない境界線を非表示にし、出力として使用するのに役立ちます:
両面ボーダー画像
コーナーカーブを取得するには、上記のコードのコメント行を削除します
<corners android:topLeftRadius="20dp"/>
曲線が曲がっていることがわかります
曲線画像付きボーダー
これxml
をframe layout
以下のように使用し、必要に応じてパディングまたはマージンを調整して、フレームのように見える境界線の画像内に収まるようにします。
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:scaleType="centerCrop"
android:src="@drawable/your_image_file" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/twoside_border" />
</FrameLayout>