【发布时间】:2016-08-18 09:13:44
【问题描述】:
我已经有一段时间被困住了。我是一个新手安卓开发者。
我有一个可绘制的圆圈。
circle_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>
请注意,我尝试将填充和边距设置为 0,但没有成功。 我也尝试通过代码设置ImageView的大小,但它只是改变了整个ImageView的大小,而不是单独的圆圈。
这就是我用这段代码得到的。
非常感谢任何帮助。
【问题讨论】:
-
如果你想用Canvas比xml画图,我可以举个例子
-
如果你愿意,我可以教你如何用指南针画画
-
@Stallion - 请务必展示
-
@lelloman - 请务必展示
标签: android xml android-layout drawable shape