综合技术

Relative arrangement in the form of a circle

微信扫一扫,分享到朋友圈

Relative arrangement in the form of a circle
0

I want to make a relative layout in the form of a circle.I don’t want to use canvas because I cannot handle clickable events in canvas.I want every event like mouse click etc to be executed within that circle only.On clicking outside the circle none of the layout event should be executed.

I have following code , circle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

   <solid
       android:color="@android:color/white"/>

   <size
       android:width="10dp"
       android:height="10dp"/>
</shape>

,img.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

   <item android:drawable="@drawable/circle"/>

</layer-list>

,layout

<RelativeLayout
        android:id="@+id/test_layout"
        android:layout_width="700px"
        android:layout_height="700px"
        android:background="@drawable/img" />

But this code is setting circle on background of relative layout, which is in the form of rectangle .Whatever the event I add to relative layout get executed outside the circle.I wish if the entire layout is a circle.How can I do that?.

Create a xml file and add in drawable folder

<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="oval" >
 <solid android:color="#65BF59"/> <!-- this one is ths color of the  Rounded Button -->
  <corners
  android:bottomRightRadius="100dp"
  android:bottomLeftRadius="100dp"
  android:topLeftRadius="100dp"
  android:topRightRadius="100dp"/>
 </shape>

Use this file in the background of your layout.

阅读原文...


微信扫一扫,分享到朋友圈

Relative arrangement in the form of a circle
0

Hello, buddy!

HierTCN: Deep learning models for dynamic recommendations and inferring user interests

上一篇

Flutter 状态管理之 ChangeNotifierProvider(Provider)

下一篇

评论已经被关闭。

插入图片

热门分类

往期推荐

Relative arrangement in the form of a circle

长按储存图像,分享给朋友