I tried to create a rectangle shape with corner radius and border on android. I almost made it, just a little problem that i cant solve until now :
The border already has some radius on its corner, but the inner rectangle does NOT (please see the red mark on the image).
This is my code :
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="10dp"/>
<stroke android:width="3dp" android:color="#000000" />
</shape>
I use this shape by using android:src
on the ImageView
.
This is how i use the shape :
<ImageView
android:src="@drawable/rectangle"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
And this is how i maintain the shape's size (on my adapter) :
holder.answer.setBackgroundColor(getItem(position).getColor());
holder.answer.getLayoutParams().width = (int) GlobalUtil.size;
holder.answer.getLayoutParams().height = (int) GlobalUtil.size;
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(holder.answer.getLayoutParams());
lp.setMargins(0, (int) GlobalUtil.gapGrid, 0, (int) GlobalUtil.gapGrid);
holder.answer.setLayoutParams(lp);
Please kindly help me out, Thanks.