当前位置: 首页 > news >正文

在线买房网站建设 方案成都房产网上政务大厅

在线买房网站建设 方案,成都房产网上政务大厅,郑东新区建设局网站,域名拦截检测网站看完控件#xff0c;紧接着看布局#xff0c;布局是可以来放置控件#xff0c;管理控件的。布局里也可以嵌套布局。我们新建项目UILayoutTest项目#xff0c;活动名和布局名选择默认。加入活动及其对应的布局已经创建完成。线性布局(LinearLayout)android:layout_gravity属…看完控件紧接着看布局布局是可以来放置控件管理控件的。布局里也可以嵌套布局。我们新建项目UILayoutTest项目活动名和布局名选择默认。加入活动及其对应的布局已经创建完成。线性布局(LinearLayout)android:layout_gravity属性 android:layout_weight属性相对布局(RelativeLayout)相对于父布局定位 相对于控件定位注意当一个控件去引用另一个控件的id时该控件一定要定义在引用控件的后面不然会找不到id的情况LinearLayout布局会将它所包含的控件在线性方向上一次排列所谓线性方向可能是垂直方向或者是水平方向前面我们都是在垂直方向上排列控件我们可以通过android:orientation属性指定了排列方向是vertical如果指定的是horizontal控件就会在水平方向上排列了。修改activity_layout.xml新增加三个按钮我们可以想不写android:orientation属性发现3个按钮根据自身大小水平排列因为这是LinearLayout布局默认的控件排列方式倘若你的第一个控件的android:layout_widthmatch_parent就是说你的一个控件的宽度等于整个屏幕的宽度那么你后面的哪个控件很有可能显示不出来。 等到我们写过android:orientationvertical我们会发现3个按钮垂直的排列了。?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:orientationverticalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityButtonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textButton 1/Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textButton 2/Buttonandroid:idid/button3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textButton 3android:textAllCapsfalse//LinearLayout 这里需要注意如果LinearLayout的排列方式是horizontal内部的控件就不能将宽度指定为match_parent因为这样单独一个控件会将整个水平方向占满其他控件就没有可以放置的位置了。同样的道理如果LinearLayout的排列方式是horizontal内部控件就不能将高度指定为match_parent因为这样单独一个控件会将整个垂直方向占满。 我们首先来看布局的android:layout_gravity属性我们之前看过android:gravity属性这两者有些相似。区别是android:gravity是指定文字在控件中的对齐方式而android:layout_gravity是指定控件在布局中的对齐方式。两者的可选值差不多但是需要注意LinearLayout的排列方向是horizontal时只有垂直方向上的对齐方式才会生效因为此时水平方向的长度是不固定的每增加一个控件水平方向上的长度都会改变因而无法指定该方向上的对齐方式。同样道理当LinearLayout的排列方向是vertical时只有水平方向上的对齐方式才会生效。修改activity_main.xml文件代码如下 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/tools android:orientationhorizontalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityButtonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_gravitytopandroid:textButton 1/Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_gravitycenter_verticalandroid:textButton 2/Buttonandroid:idid/button3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_gravitybottomandroid:textButton 3android:textAllCapsfalse//LinearLayout 我们再来看LineraLayout中另一个重要属性android:layout_weight。它允许我们使用比例的方式来指定控件的大小它可以去适应手机的屏幕。下面我们来编辑一个消息发现界面需要一个文本编辑框和一个发送按钮修改activity_main.xml中的代码如下所示: ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:orientationhorizontalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityEditTextandroid:idid/input_messageandroid:layout_width0dpandroid:layout_heightwrap_content android:layout_weight3android:hintType something/Buttonandroid:idid/sendandroid:layout_width0dpandroid:layout_heightwrap_content android:layout_weight2android:textSend//LinearLayout 发现EditText和Button的宽度都指定为了0dp不过你不用担心文本编辑框和按钮不存在因为我们又接着使用了android:layout_weight属性此时控件大小由android:layout_weight来决定。这里0dp是一种比较规范的写法。另外dp是Android中用于指定控件大小、间距等属性的单位。在这里我们把EditText和Button的android:layou_weight分别设置为3和2这表明EditText占整个屏幕宽度的3份Button占2份我们是将整个屏幕分为32份。 当然我们也可以只是指定部分控件的layout_weight值来实现更好的效果。修改activity_main.xml文件中的代码如下 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:orientationhorizontalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityEditTextandroid:idid/input_messageandroid:layout_width0dpandroid:layout_heightwrap_contentandroid:layout_weight3android:hintType something/Buttonandroid:idid/sendandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSend//LinearLayout 我们只是指定了EditText的android:layout_weight属性并将Button的宽度改为wrap_content。这表明Button的宽度仍然按照wrap_content来计算而EditText则会占满屏幕的所有剩余空间。相对布局(RelativeLayout)android:layout_alignParentLeft属性可以让控件和父布局的左上角对齐android:layout_above属性可以让一个控件位于另一个控件的上方android:layout_alignLeft表示让一个控件的左边缘和另一个控件的左边缘对齐 相比较LinearLayoutRelativeLayout更加随意一些它通过相对定位的方式让控件出现在布局的任何位置。正因为如此RelativeLayout的属性非常多不过都是有规律可循的。修改activity_main.xml中的代码如下 ?xml version1.0 encodingutf-8? RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:orientationhorizontalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityButtonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_alignParentToptrueandroid:textbutton 1/Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentRighttrueandroid:layout_alignParentToptrueandroid:textbutton 2/Buttonandroid:idid/button3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerInParenttrueandroid:textbutton 3/Buttonandroid:idid/button4android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_alignParentBottomtrueandroid:textbutton 4/Buttonandroid:idid/button5android:textAllCapsfalseandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentBottomtrueandroid:layout_alignParentRighttrueandroid:textbutton 5//RelativeLayout 我们让Button 1和父布局的左上角对齐Button 2和父布局的右上角对齐Button 3居中显示Button 4 和父布局的左下角对齐Button 5 和父布局的右下角对齐。程序运行如下上面这是相对于父布局定位。 下面我们相对于控件进行定位。 修改activity_main.xml中的代码如下 ?xml version1.0 encodingutf-8? RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:orientationhorizontalandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:contextcom.example.uilayouttest.MainActivityButtonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_content android:layout_aboveid/button3android:layout_toLeftOfid/button3android:textbutton 1/Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_aboveid/button3android:layout_toRightOfid/button3android:textbutton 2/Buttonandroid:idid/button3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerInParenttrueandroid:textbutton 3/Buttonandroid:idid/button4android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_belowid/button3android:layout_toLeftOfid/button3android:textbutton 4/Buttonandroid:idid/button5android:textAllCapsfalseandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_belowid/button3android:layout_toRightOfid/button3android:textbutton 5//RelativeLayout 其中android:layout_above属性可以让一个控件位于另一个控件的上方需要为这个属性指定相对控件的id的引用。 android:layout_toLeftOf表示一个控件位于另一个控件的左侧。注意当一个控件去引用另一个控件的id时该控件一定要定义在引用控件的后面不然会找不到id的情况。重新运行程序如下图RelativeLayout中还有另外一组相对于控件进行定位的属性android:layout_alignLeft表示让一个控件的左边缘和另一个控件的左边缘对齐android:layout_alignRight、android:layout_alignTop、android:layout_alignBottom道理是一样的。
http://www.lebaoying.cn/news/59010.html

相关文章:

  • 网站主体备案wordpress主题个人博客
  • 网站开发进度把握寓意好的公司名字大全免费
  • 陕西省建设厅证网站号多少html网页模板之家
  • 中国矿井建设相关媒体网站网站建设和维护公司
  • 做网站还是做微信公众号做网站好还是做微信小程序好
  • 做外贸找产品上哪个网站好网站logo怎么换
  • jsp个人网站设计重庆个人网络营销定制
  • 网站制作长沙兰州新增94个高风险区
  • 怎么用ai做企业网站框架四川建设岗培注册中心官网
  • 电商网站建设技术如何备份wordpress数据库
  • 如何做微网站平台网页设计与制作论文6000
  • 网站手机版后台wordpress 文章删除
  • 网站建设word文档wordpress 敏感词过滤
  • 广西网站建设性价比高手机python编程软件
  • 网站开发服务器的选择定制建设网站
  • dede英文网站建造师在建设部网站何时更新
  • 高端汽车网站建设浙江商会网站建设策划方案
  • 设计网站建设的合同书免费自己做网站
  • 成都哪里有做网站的公司免费设计海报的软件
  • 六安建设局网站虚拟商品自动发货网站搭建教程
  • 廊坊建站软件wordpress 提高速度慢
  • 如何韩国视频网站模板下载 迅雷下载电商网站的费用怎么做帐
  • 做音乐网站电商网站建设计入什么科目
  • html5开发的网站wordpress网易云音乐插件
  • 专业外贸网站做网站制作较好的公司
  • 手机网站后台云浮东莞网站建设
  • 微信分享网站显示图片舞蹈网站模版
  • h5网站建设包括什么设计师做单页的网站
  • 网站规划 评价合肥搜索优化排名
  • 网站后台培训北京建设银行分行招聘网站