android:orientation指定LinearLayout布局方向,值:vertical
(垂直方向) 、horizontal(水平方向)实例一:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><Button android:layout_width="match_parent"android:layout_height="wrap_content"android:t...
推荐android studio一个插件,可以将布局分组的效果图:地址:https://github.com/dmytrodanylyk/folding-pluginInstallationDownload latest Android File Grouping zip file hereOpen AS Settings, and select PluginsClick Install from disk and choose Android File Grouping.zipRestartUsageRick click on layout folder (or any other)In context menu click Group/Ungroup原文:http://my.oschina.net/u/244918/blog/484189
<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" >
<TextView
android:id="@+id/top_tv"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#ffffff"
android:gravity="c...
一、线性布局LinearLayout又称为线性布局,是一种非常常用的布局。这个布局会将它包含的控件在线性方向上依次排列。我们可以通过指定它的orientation属性来决定它是垂直方向排列还是水平方向上排列。举例1:垂直方向排列
当排列方向是vertical,内部控件就不能将高度指定为match_parent ## 举例2:水平方向排列 如果LinearLayout的排列方向是horizontal,内部控件就绝对不能将宽度指定为match_parent。举例3:layout_gravity属性
...
<该文章参考各大博客以及书籍总结而来,如有问题欢迎指出^ ^>一、五大传统布局+新布局线性布局——LinearLayout相对布局——RelativeLayout帧布局——FrameLayout绝对布局——AbsoluteLayout表格布局——TableLayout约束布局——ConstraintLayout二、介绍(一)LinearLayout1.简介线性布局,是最常用的布局之一,这个布局会将它所包含的控件在线性方向上依次排列,排列方向可以设定为水平方向或垂直方向。2.属性 排列方向:1 andro...
采用GridView动态布局,多个按钮样式相同,只是文字不同,采用这种方式可以省事一些,技术含量更高。privatevoid initTextBtns() {for (String btn : mTextBtns) {mTextBtnsList.add(btn);}}参考资料:http://www.cnblogs.com/hbuwyg/p/6959320.html原文:http://www.cnblogs.com/hbuwyg/p/7003070.html
框架布局是最简单的布局方式,所有添加到这个布局中的视图都是以层叠的方式显示,第一个添加到布局中的视图显示在最底层,最后一个被放在最顶层,上一层的视图会覆盖下一层的视图。该框架类似堆栈布局.默认是组件都放在左上角.一、将几张图片拷贝到/res/drawable-hpdi目录下<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_pa...
RelativeLayout可以设置某一个视图相对于其他视图的位置,这些位置可以包括上下左右等 RelativeLayout 属性 说明 android:layout_below 在某一个元素的下方 android :layout_above 在某一个元素的下方 android: layout_toLeftOf 在某一个元素左边 android: layout_toRightOf 在某一个元素的右边原文:http://www.cnblogs.com/dx-q/p/6014230.html
序:本文讲RelativeLayout两点:1. 简单例子说明RelativeLayout使用方法 2.强调<RelativeLayout android:gravity="center"/> 用gravity 而不是用layout_gravity来总体设定RelativeLayout容器中子元素整体对齐方式。-----------------------------------------------------------------------------------------------------------------------1.简介相对布局RelativeLayout RelativeLayout可以设置某一视图相对于其他视图的位置...
RelativeLayout用到的一些重要的属性:第一类:属性值为true或falseandroid:layout_centerHrizontal 水平居中android:layout_centerVertical 垂直居中android:layout_centerInparent 相对于父元素完全居中android:layout_alignParentBottom 贴紧父元素的下边缘android:layout_alignParentLeft 贴紧父元素的左边缘android:layout_alignParentRight 贴紧父元素的右边缘android:layout_alignParentTop 贴紧父元素的上边缘android:layou...
所谓的嵌套布局就是在一个文件中嵌套多个布局文件<span style="font-size:18px;"> <LinearLayoutandroid:layout_width="match_parent"android:layout_height="fill_parent"android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"android:layout_height="fill_parent"android:orientation="vertical" >
……
……
……
</FrameLayout ></LinearLayout></span>
接下来使用嵌套布局来实现一个简单计算...
// ConstraintLayout.LayoutParams linearParams =(ConstraintLayout.LayoutParams) imDanci.getLayoutParams();
//// 2.设置布局的高度 后面的参数就是对应xml中的 42dp 可以根据需要进行改变
// linearParams.height=((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, ConstraintLayout.LayoutParams.WRAP_CONTENT, getResources().getDisplayMetrics()));
//// 3.最后设置下控件的布局就可以了
//...
写完博客的总结 : 以前没有弄清楚的概念清晰化父容器与本容器属性 :
android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中,
每个布局管理器都有一个LayoutParams内部类, android:... 是父容器用来控制子组件的属性. 如android:layout_gravity
是控制组件本身的对齐方式, android:gravity是控制本容器子组件的对齐方式; 布局管理器都是以ViewGroup为基类派生出来的;
使用布局管理器可以适配不同手...
先明确几个概念的区别: padding margin都是边距的含义,关键问题得明白是什么相对什么的边距. padding是控件的内容相对控件的边缘的边距. margin是控件边缘相对父控件的边距. android:gravity 属性是对该view 内容的限定.比如一个button 上面的text. 你可以设置该text 在view的靠左,靠右等位置.该属性就干了这个. android:layout_gravity是用来设置该view中的子view相对于父view的位置.比如一个button 在linearlayout里...
一个FrameLayout对象就好比一块屏幕上提前预定好的空白区域,然后可以填充一些元素到里边,比方说一张图片等。需要注意的是,所有的元素都被放置在FrameLayout区域最左边上的区域。而且无法为这些元素指定一个确切的位置。如果一个FrameLayout里边有多个子元素,那么后边的子元素的显示会重叠在前一个元素上。实例:LayoutDemo
运行效果:
代码清单:
布局文件:frame_layout.xml<?xml version="1.0" encoding="utf-8"?>
<FrameLay...