画面サイズに関係なく、すべての Android デバイスで同じ直径 2.5 インチ (またはその他の値) の円を描画しようとしています。直径のサイズはすべてのデバイスで同じでなければならず、以下は私が試したものです。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="@drawable/light"
tools:context=".MainActivity">
<ImageView
android:layout_width="3in"
android:layout_height="3in"
android:src="@drawable/oval_shape"
android:id="@+id/imageView"
android:scaleType="matrix"/>
</RelativeLayout>
oval_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#666666"/>
<size
android:width="2.5in"
android:height="2.5in"/>
</shape>
このコードの問題は、4.5 インチの画面 (実際の電話) で試してみると、直径は予想どおり 2.5 インチですが、4 インチの画面でテストすると直径が 2.5 インチ未満で、わずかな違いがあります。ミリメートル(mm)も使ってみましたが、うまくいきませんでした。
では、すべての電話で同じサイズの円の要件をどのように達成できますか?