Ani*_*abu 5 xml android shape drawable android-layout
有一段时间我一直坚持这个。我是一个新手android开发者。
我有一个可绘制的圆圈。
圆形形状.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>
Run Code Online (Sandbox Code Playgroud)
现在我想在我的活动布局中使用这个圆圈,使其覆盖整个屏幕。也就是说,屏幕的宽度应该等于圆的直径。请注意,我没有设置圆的半径。
示例_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>
Run Code Online (Sandbox Code Playgroud)
请注意,我曾尝试将填充和边距设为 0,但没有奏效。我也尝试过通过代码设置ImageView的大小,但它只是整体改变ImageView的大小,而不是单独改变圆形。
这就是我用这段代码得到的。
任何帮助是极大的赞赏。
你可以试试这个代码:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:thickness="0.8dp"
android:useLevel="false"
android:innerRadiusRatio="2.1">
<solid android:color="@android:color/holo_blue_dark" />
</shape>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4757 次 |
最近记录: |