如何让安卓(Android)子控件超出父控件的范围显示

下面我们来看一下关于安卓(Android)子控件超出父控件的范围显示出来的方法,希望这篇文章能够帮助到各位安卓(Android)的开发者们,有碰到此问题的朋友可以进来看看哦。

废话不多说,直接上代码:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android"
  android:layout_width= "match_parent"
  android:layout_height= "match_parent"
  android:clipChildren= "false" >
  
  <ImageView
   android:layout_width= "match_parent"
   android:layout_height= "match_parent"
   android:layout_marginBottom= "60dp"
   android:background= "@mipmap/www" />
  
  
  <LinearLayout
   android:id= "@+id/ll_bottom"
   android:layout_width= "match_parent"
   android:layout_height= "60dp"
   android:layout_alignParentBottom= "true"
   android:background= "#F8549D"
   android:elevation= "10dp"
   android:orientation= "horizontal" >
  
   <RelativeLayout
    android:layout_width= "0dp"
    android:layout_height= "match_parent"
    android:layout_gravity= "bottom"
    android:layout_weight= "1" >
  
    <ImageView
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:layout_centerInParent= "true"
     android:src= "@mipmap/ic_launcher" />
  
   </RelativeLayout>
  
   <RelativeLayout
    android:layout_width= "0dp"
    android:layout_height= "match_parent"
    android:layout_gravity= "bottom"
    android:layout_weight= "1" >
  
    <ImageView
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:layout_centerInParent= "true"
     android:src= "@mipmap/ic_launcher" />
  
   </RelativeLayout>
  
   <RelativeLayout
    android:layout_width= "70dp"
    android:layout_height= "70dp"
    android:layout_gravity= "bottom"
    android:background= "@drawable/bottom_bg_shape" >
  
    <ImageView
     android:layout_width= "30dp"
     android:layout_height= "30dp"
     android:layout_centerInParent= "true"
     android:src= "@mipmap/icon_go" />
  
   </RelativeLayout>
  
  
   <RelativeLayout
    android:layout_width= "0dp"
    android:layout_height= "match_parent"
    android:layout_gravity= "bottom"
    android:layout_weight= "1" >
  
    <ImageView
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:layout_centerInParent= "true"
     android:src= "@mipmap/ic_launcher" />
  
   </RelativeLayout>
  
   <RelativeLayout
    android:layout_width= "0dp"
    android:layout_height= "match_parent"
    android:layout_gravity= "bottom"
    android:layout_weight= "1" >
  
    <ImageView
     android:layout_width= "wrap_content"
     android:layout_height= "wrap_content"
     android:layout_centerInParent= "true"
     android:src= "@mipmap/ic_launcher" />
  
   </RelativeLayout>
  </LinearLayout>
  
</RelativeLayout>
 

这张图呢是我刚刚做的,效果是参考了酷狗音乐播放器来完成的,我想说明重点在底部的导航栏:如图


再来一张反效果预览图:


如何使得蓝色圆形的播放键的显示越过粉色的范围。当然经过合理的布局是可以达到这样的效果的,但是却有更简单的方法。也就是在根布局的属性中加入一个来自Android自身提供的属性:

?
1
android:clipChildren= "false"

属性解释和说明:

    1、android:clipChildren的意思:是否限制子View在其范围内

     2、可以通过android:layout_gravity控制超出的部分如何显示。

    3、只需在根节点设置android:clipChildren为false即可,默认为true

总结

以上就是如何让安卓(Android)子控件超出父控件的范围显示出来的全部内容,大家学会了吗?希望本文可以帮助到各位。






  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值