我目前正在使用drawable来获取环形图像视图。RingShapeDrawable的半径设置为父宽高度而不是宽度
问题是:我有两个这些imageviews所有与weight = 1,所以他们都有相同的宽度。形状环drawable的xml标签属性“innerRadiusRatio”依赖于drawable的宽度。因此,如果图像视图的宽度变得比高度大,则环形形状将被裁剪。有什么办法可以让innerRadiusRatio依赖高度而不是宽度?甚至将其scaleType设置为“fitCenter”或类似的东西?
这里是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="64dip"
android:layout_width="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ring_shape_drawable"
android:src="@drawable/test_button_drawable"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ring_shape_drawable"
android:src="@drawable/test_button_drawable"/>
</LinearLayout>
这里的形状绘制的XML:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="2.8"
android:thicknessRatio="30"
android:useLevel="false"
android:shape="ring" >
<solid android:color="@color/custom_red" />
</shape>
而这里的结果(与裁剪ringShapeDrawable我不希望):
这将是理想的结果:
感谢您的帮助:)
您的drawables是XML吗?如果是这样,让他们。 – anthropomo
可绘制的形状没有什么特别的。但无论如何,我编辑了我的问题,并添加到它的XML。 – MrMaffen