简体   繁体   English

如何在 React-Native 上制作真正的圆形 TocuhableOpacity? UI 部分看起来是圆形的,但 clicke 事件仍然是矩形的

[英]How can i make truly circular TocuhableOpacity on React-Native ? UI part is seeming circular but clicke event is still rectangular

i want to ask how can i make TouchableOpacity completely circular?我想问我怎样才能使 TouchableOpacity 完全圆形? This is some kind a tricky issue for me because ui side is seemings circular shape but when i try to click edges as thinking its a rectangular, click events triggering from edges.这对我来说是一个棘手的问题,因为 ui 侧似乎是圆形,但是当我尝试单击边缘时认为它是矩形时,单击事件会从边缘触发。 I don't want that at all.我根本不想要那个。 I want fully circular shaped button for both ui & click event sides.我想要 ui 和 click 事件侧的完全圆形按钮。 I'd be appreciated if you could help me, Thanks.如果您能帮助我,我将不胜感激,谢谢。 Best regards.此致。

            <TouchableOpacity
                style={{
                    width: 50,
                    height: 50,
                    borderRadius: 100,
                    alignItems: "center",
                    justifyContent: "center",
                }}
                pressRetentionOffset={0.5}
                onPress={() => { }}>

                {/* some kind of codes here... */}
     
            </TouchableOpacity>

write a code like this and try编写这样的代码并尝试

<TouchableOpacity
   style={{
     borderColor:'black',
     alignItems:'center',
     justifyContent:'center',
     width:100,
     height:100,
     borderRadius:50,
   }}
 >
     {=====some write a code here====}
 </TouchableOpacity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM