我正在try 将Make an ImageView的角用纯XML舍入到一个Home Screen窗口小部件中.我在v31和更高版本中使用android:clipToOutline="true"
,但由于我的应用程序支持更低的版本,我不能一直使用它.这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="9dp"
android:background="@drawable/widget_background"
android:padding="9dp"
android:id="@+id/widget_container"
android:orientation="horizontal">
<TextView
android:id="@+id/default_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25sp"
android:textStyle="bold"
android:gravity="center"
android:textColor="#E9E9E9"
tools:text="Nothing yet!" />
<ImageView
android:id="@+id/scribb_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:background="@drawable/image_background"
android:contentDescription="@string/image" />
</LinearLayout>
image_background.xml
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="9dp"/>
</shape>
这是一个Flutter 项目,所以我尽量不使用太多的依赖项.