Android 大于其所在视图的可绘制形状
Android shape drawable that is larger than the view it's in
我有一个可绘制圆形背景的视图。我希望圆圈比它包含的视图大,但仍被剪掉。问题是,drawable 的大小不想超出视图的大小,整个圆比我需要的要小得多。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:background="@drawable/circle" />
</RelativeLayout>
和 circle.xml:
<shape android:shape="oval">
<solid android:color="#ff0000" />
</shape>
我怎样才能得到大裁剪圆圈?
<shape android:shape="oval">
<size android:width="50dp" android:height="50dp" />
<solid android:color="#ff0000" />
</shape>
如果问题仍然存在,您可能需要使用 ImageView 和 setImageResource 而不是视图和背景。
确保在视图父级及其父级中设置 android:clipChildren="false"
属性。
我有一个可绘制圆形背景的视图。我希望圆圈比它包含的视图大,但仍被剪掉。问题是,drawable 的大小不想超出视图的大小,整个圆比我需要的要小得多。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:background="@drawable/circle" />
</RelativeLayout>
和 circle.xml:
<shape android:shape="oval">
<solid android:color="#ff0000" />
</shape>
我怎样才能得到大裁剪圆圈?
<shape android:shape="oval">
<size android:width="50dp" android:height="50dp" />
<solid android:color="#ff0000" />
</shape>
如果问题仍然存在,您可能需要使用 ImageView 和 setImageResource 而不是视图和背景。
确保在视图父级及其父级中设置 android:clipChildren="false"
属性。