android:clipChildren妙用:底部的radioGroup中间的button突出
2016-08-18 16:07
561 查看
在我不知道这个属性之前,底部菜单栏的布局需要写RelativeLayout来完成,但是,在我知道之后,妈妈再也不让我用RelativeLayout了。
接下来,先认识下android:clipChildren这个属性:是否限制子View在其范围内,默认为true,在这里,我们需要把他设置为false。
先看下用了这个属性之后,实现这个布局的代码:
[java] view
plain copy
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:clipChildren="false"
android:gravity="bottom"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#234221"
android:gravity="bottom" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
是不是感觉很惊讶,不用什么RelativeLayout布局,也不用重叠,简单的LinearLayout就可以轻松实现.只需以下步骤:
1、只需在根节点设置android:clipChildren为false即可,默认为true(经过测试,其实是在他爹的爹设置,也就是他爷爷节点设置)
2、可以通过android:layout_gravity控制超出的部分如何显示。
在我不知道这个属性之前,底部菜单栏的布局需要写RelativeLayout来完成,但是,在我知道之后,妈妈再也不让我用RelativeLayout了。
接下来,先认识下android:clipChildren这个属性:是否限制子View在其范围内,默认为true,在这里,我们需要把他设置为false。
先看下用了这个属性之后,实现这个布局的代码:
[java] view
plain copy
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:clipChildren="false"
android:gravity="bottom"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#234221"
android:gravity="bottom" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
是不是感觉很惊讶,不用什么RelativeLayout布局,也不用重叠,简单的LinearLayout就可以轻松实现.只需以下步骤:
1、只需在根节点设置android:clipChildren为false即可,默认为true(经过测试,其实是在他爹的爹设置,也就是他爷爷节点设置)
2、可以通过android:layout_gravity控制超出的部分如何显示。
相关文章推荐
- 自定义控件学习:设置自定义控件的属性
- android中的触摸事件
- Android开发之BroadcastReceiver
- android MVC MVP MVVM如何区分
- ubuntu下搭建android开发环境
- Android 文件选择的使用
- android混淆之从异常堆栈中还原ProGuard混淆过的代码
- Android中的dispatchTouchEvent()、onInterceptTouchEvent()和onTouchEvent()
- android studio默认修改主题,字体,文字颜色,大小等属性的设置
- Android Studio 2.1.2
- Android常用的代码块及工具类大放送
- Android设计中的.9.png与Android Studio中的设置
- 45.实现自定义View拖拽效果的5种方法
- android studio如何修改默认的sdk的位置。、
- 不管是Wifi 、还是 4G 下都可以获取公网IP地址
- Android 进程保活招式大全
- Android: EditText监听内容变化
- Android自定义实现BaseAdapter的普通实现
- Android Studio 0.4 + PhoneGap 3.3 开发环境的搭建
- 透明状态栏和沉浸式