将我的布局转换为圆环形状 [英] convert my layout into a circular ring shape

查看:153
本文介绍了将我的布局转换为圆环形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的线形布局成环状。

I want to make my linear-layout in ring shape.

我跟着这个链接,但我没有戒指布局,而是我得到一个圆形布局。

I followed this Links but i doesn't got ring layout instead I am getting a circular layout.

https://developer.android.com/guide/topics/ resources / drawable-resource.html#Shape

如何在xml中创建以下布局以用作我的android活动的背景?

我的xml

<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ring.MainActivity" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@drawable/ring"
    >

</LinearLayout>

和draw.xml中的drawable

and ring.xml in drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="ring"
 android:innerRadius="90dp"
 android:thickness="10dp"
 android:useLevel="false" >

<solid android:color="#ababf2" />

我刚刚得到一个我的布局中的圆圈没有响。因为我的声誉很短,我无法上传我的输出图像。

and I am just getting a circle in my layout not ring.Sorry i cannot upload an image of my output because of my short reputation.

推荐答案

试试这个:

ring.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="50dp"
android:thickness="2dp"
android:useLevel="false">
<stroke android:width="2dp"
    android:color="#ababf2"/>
<solid android:color="@android:color/transparent" />

</shape>

你的xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<RelativeLayout
        android:id="@+id/rel"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_centerInParent="true"
        android:background="@drawable/ring" >
    </RelativeLayout>
</RelativeLayout>

这篇关于将我的布局转换为圆环形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆