它已經有一段時間了,我一直堅持這一點。我是一個新手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 - 請確實顯示 –