正如你可以看到here我尝试为我的FrameLayout制作圆角。这是我的rounded_shape.xml形状:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke android:width="@dimen/margin"
android:color="@color/colorBackground"/>
<corners android:radius="24dp" />
</shape>
这看起来如此:rounded_shape.xml Preview
当我在我的代码中执行:frameLayout.setBackground(new BitmapDrawable(getResources(),bitmapPhoto.bitmap)); frameLayout.setForeground(getResources()getDrawable(R.drawable.rounded_shape));它看起来像这样:result on app
您可以通过圆角看到黑色边缘。
我怎么能做这样的形状:where the the edges are rounded and the black parts are gone already
我做了两个平行的形状。
所有结构都在layer-list
中,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="@dimen/margin"
android:color="@color/color" />
<corners android:radius="24dp" />
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="@dimen/margin"
android:color="@color/color" />
</shape>
</item>
</layer-list>