1
我正在開發一個Android應用程序。在我的應用程序中,我打開了一個像對話框一樣的活動。對於那個活動背景,我想設置整個背景的圖像,但是具有邊框半徑。所以我創建了這樣的背景XML資源。在Android中使用圖像定製XML可繪製資源
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/match_background_image" />
<item>
<shape android:shape="rectangle" android:padding="10dp">
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
</shape>
</item>
</layer-list>
我將該資源設置爲LinearLayout的背景。當我打開活動中,我得到的是這樣的:
正如你可以看到有在角落沒有邊界半徑。此外,我想要做的是我也想要將scaleType設置爲cropCenter作爲圖像。那麼是否有可能只是在XML資源中完成?