Android layout 如何将ShapeDrawable与xml布局资源一起使用

Android layout 如何将ShapeDrawable与xml布局资源一起使用,android-layout,Android Layout,我希望能够在我的布局文件中定义一个ShapeDrawable,然后将其膨胀,以便在其上绘图。 我已经在android开发者的网站上学习了教程,但是我看不到我如何在我的主类文件中引用我的ShapeDrawable 我该如何给它充气呢 我已将以下内容放入布局文件: <com.example.shapedrawable.CustomDrawableView android:id="@+id/customDrawableView" android:layout_width="fi

我希望能够在我的布局文件中定义一个ShapeDrawable,然后将其膨胀,以便在其上绘图。 我已经在android开发者的网站上学习了教程,但是我看不到我如何在我的主类文件中引用我的ShapeDrawable

我该如何给它充气呢

我已将以下内容放入布局文件:

<com.example.shapedrawable.CustomDrawableView 
    android:id="@+id/customDrawableView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

一旦在自己的XML文件中定义了ShapeDrawable,就需要将以下内容添加到layout.XML中,以便将其包含在其中:

<ImageView
    android:src="@drawable/shapeDrawable_filename"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

如果你想以编程的方式来做,我还没有答案,但是从你的问题来看,这应该是可行的

如果有帮助,请告诉我;)