它已经有一段时间了,我一直坚持这一点。我是一个新手android开发人员。根据屏幕尺寸缩放可绘制圆圈
我有一个可绘制的圆。
circular_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:useLevel="false"
android:shape="ring"
android:thickness="0.8dp">
<solid android:color="@android:color/holo_blue_dark"/>
</shape>
现在我想用在我的活动布局这个圈子,因为它覆盖了整个屏幕的方式。也就是说,屏幕的宽度应该等于圆的直径。 请注意,我没有设置圆的半径。
example_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/exampleLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anil.raceorganizer.ExampleActivity">
<ImageView
android:id="@+id/race_field"
android:src="@drawable/circular_shape"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:padding="0dp"
android:layout_margin="0dp"
></ImageView>
</FrameLayout>
请注意,我试图把padding和margin为0,但没有奏效。 我也尝试通过代码设置ImageView的大小,但它只是改变了ImageView的整体大小,而不是单独循环。
这就是我用这段代码得到的结果。
任何帮助是极大的赞赏。
如果你想使用画布绘制图像比XML,我可以给和示例 – Stallion
如果你想我可以告诉你如何用画指南针 – lelloman
@Stallion - 请确实显示 –