RelativeLayout中的位置属性

2023-12-21 19:32

本文主要是介绍RelativeLayout中的位置属性,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

<p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);">1、 相对布局的基本概念 <br style="margin: 0px; padding: 0px;" />一个控件的位置它决定于它和其他控件的关系,好处:比较灵活;缺点:掌握比较复杂。 <br style="margin: 0px; padding: 0px;" />2、 相对布局常用属性介绍 <br style="margin: 0px; padding: 0px;" />这里将这些属性分成4个组,便于理解和记忆。 <br style="margin: 0px; padding: 0px;" />a)、以下4个属性设置控件与之间的关系和位置 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109500394.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />但是上面4个属性并没有设置各个控件之间是否对齐。 <br style="margin: 0px; padding: 0px;" />示例1:将控件A放置在控件B的上面,则使用android:layout_above属性,控件布局的效果可以有以下这么两种情况。 <br style="margin: 0px; padding: 0px;" />1、 控件A与控件B对齐,并且控件A是在控件B的上面。 <br style="margin: 0px; padding: 0px;" />2、 控件A没有与控件B对齐,但是控件A又确实是在控件B的上面。 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109501874.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"> </p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109502928.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />b)、以下5个属性,设置的是控件与控件之间对齐的方式(是顶部、底部还是左、右对齐)。 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109504048.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />示例2:在示例1的基础上,设置控件A放置在控件B的上面,使用android:layout_above属性,并且控件A的右边边缘与控件B的右边边缘对齐,使用android:layout_alignRight属性。 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109505182.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />c)、以下4个属性设置控件与父控件之间对齐的方式(是顶部、底部还是左、右对齐)。 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109510137.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />d)、以下4个属性设置控件的方向。 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109511276.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />可以通过组合这些属性来实现各种各样的布局。 <br style="margin: 0px; padding: 0px;" />注:以上属性和其他更多属性的作用都能在android的帮助文档中找到; <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />示例3:假如要实现一个如下图这样布局的程序 <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109512937.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" />如果这样的布局要使用LinearLayout的话会比较麻烦和复杂, <br style="margin: 0px; padding: 0px;" />1、 首先需要一个垂直布局方向的LinearLayout,包裹所有的控件; <br style="margin: 0px; padding: 0px;" />2、 然后在第一个LinearLayout中嵌套一个垂直方向的LinearLayout,放在上部分,在这个LinearLayout中放入一个TextView和EditText; <br style="margin: 0px; padding: 0px;" />3、 最后还是在第一个LinearLayout中嵌套一个水平方向的LinearLayout,放在第一个LinearLayout的下部分,在这个LinearLayout中放入两个Button,并且还得让它们居右。 <br style="margin: 0px; padding: 0px;" />可参考下图: <br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><img src="http://pic002.cnblogs.com/images/2011/168345/2011120109514498.jpg" alt="" style="border: 0px; max-width: 100%; margin: 0px; padding: 0px;" /></p><p style="margin: 5px auto; padding-top: 0px; padding-bottom: 0px; color: rgb(57, 57, 57); font-family: verdana, 'ms song', Arial, Helvetica, sans-serif; line-height: 21px; background-color: rgb(250, 247, 239);"><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />如果使用RelativeLayout会要简单很多,下面为main.xml的代码。 </p><div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; width: 1045px; overflow: auto; padding: 1px 0px 0px; color: rgb(57, 57, 57); line-height: 21px; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="padding: 0px 0px 0px 45px; margin: 0px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); margin: 0px; background-color: rgb(248, 248, 248);">Java代码 </div></div><ol class="dp-j" start="1" style="padding: 0px 0px 0px 50px; border: none; color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important; background-color: rgb(255, 255, 255);"><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"><?xml version=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"1.0"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> encoding=</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"utf-8"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?>  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><RelativeLayout xmlns:android=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"http://schemas.android.com/apk/res/android"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    android:layout_width=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"fill_parent"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    android:layout_height=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    android:padding=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"10px"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    >  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <TextView  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:id=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@+id/lable"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:text=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"Type here:"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_width=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"fill_parent"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_height=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    />  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <EditText  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:id=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@+id/entry"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_width=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"fill_parent"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_height=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:background=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@android:drawable/editbox_background"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_below=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@id/lable"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    />  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <Button  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:id=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@+id/ok"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_width=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_height=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:text=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"OK"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_below=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@id/entry"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_marginLeft=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"10px"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_alignParentRight=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"true"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    />  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">      </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    <Button  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:id=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@+id/cancel"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_width=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_height=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"wrap_content"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_toLeftOf=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@id/ok"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:layout_alignTop=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"@id/ok"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">        android:text=<span class="string" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"Cancel"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">  </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">    />  </span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); list-style: decimal outside; line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(248, 248, 248);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"></RelativeLayout>  </span></li></ol></div><span style="line-height: 22px;">3.</span><span style="font-size: 10px;">gravity和layout_gravity</span>
<span style="line-height: 26px; font-size: 10px;">android:gravity</span><span style="line-height: 26px; font-size: 10px;">  </span><br style="line-height: 26px; font-size: 10px;" /><span style="line-height: 26px; font-size: 10px;">android:gravity属性是对该view 内容的限定.比如一个button 上面的text.  你可以设置该text 在view的靠左,靠右等位置.以button为例,android:gravity="right"则button上面的文字靠右 </span><br style="line-height: 26px; font-size: 10px;" /><br style="line-height: 26px; font-size: 10px;" /><span style="line-height: 26px; font-size: 10px;">android:layout_gravity</span><span style="line-height: 26px; font-size: 10px;"> </span><br style="line-height: 26px; font-size: 10px;" /><span style="line-height: 26px; font-size: 10px;">android:layout_gravity是用来设置该view相对与起父view 的位置.比如一个button 在linearlayout里,你想把该button放在靠左、靠右等位置就可以通过该属性设置.以button为例,android:layout_gravity="right"则button靠右 </span>

这篇关于RelativeLayout中的位置属性的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/521227

相关文章

滚雪球学Java(87):Java事务处理:JDBC的ACID属性与实战技巧!真有两下子!

咦咦咦,各位小可爱,我是你们的好伙伴——bug菌,今天又来给大家普及Java SE啦,别躲起来啊,听我讲干货还不快点赞,赞多了我就有动力讲得更嗨啦!所以呀,养成先点赞后阅读的好习惯,别被干货淹没了哦~ 🏆本文收录于「滚雪球学Java」专栏,专业攻坚指数级提升,助你一臂之力,带你早日登顶🚀,欢迎大家关注&&收藏!持续更新中,up!up!up!! 环境说明:Windows 10

POJ1269 判断2条直线的位置关系

题目大意:给两个点能够确定一条直线,题目给出两条直线(由4个点确定),要求判断出这两条直线的关系:平行,同线,相交。如果相交还要求出交点坐标。 解题思路: 先判断两条直线p1p2, q1q2是否共线, 如果不是,再判断 直线 是否平行, 如果还不是, 则两直线相交。  判断共线:  p1p2q1 共线 且 p1p2q2 共线 ,共线用叉乘为 0  来判断,  判断 平行:  p1p

Linux Centos 迁移Mysql 数据位置

转自:http://www.tuicool.com/articles/zmqIn2 由于业务量增加导致安装在系统盘(20G)磁盘空间被占满了, 现在进行数据库的迁移. Mysql 是通过 yum 安装的. Centos6.5Mysql5.1 yum 安装的 mysql 服务 查看 mysql 的安装路径 执行查询 SQL show variables like

PDFQFZ高效定制:印章位置、大小随心所欲

前言 在科技编织的快节奏时代,我们不仅追求速度,更追求质量,让每一分努力都转化为生活的甜蜜果实——正是在这样的背景下,一款名为PDFQFZ-PDF的实用软件应运而生,它以其独特的功能和高效的处理能力,在PDF文档处理领域脱颖而出。 它的开发,源自于对现代办公效率提升的迫切需求。在数字化办公日益普及的今天,PDF作为一种跨平台、不易被篡改的文档格式,被广泛应用于合同签署、报告提交、证书打印等各个

HTML5自定义属性对象Dataset

原文转自HTML5自定义属性对象Dataset简介 一、html5 自定义属性介绍 之前翻译的“你必须知道的28个HTML5特征、窍门和技术”一文中对于HTML5中自定义合法属性data-已经做过些介绍,就是在HTML5中我们可以使用data-前缀设置我们需要的自定义属性,来进行一些数据的存放,例如我们要在一个文字按钮上存放相对应的id: <a href="javascript:" d

Python中的属性装饰器:解锁更优雅的编程之道

引言 在Python的世界里,装饰器是一个强大的工具,它允许我们以一种非侵入性的方式修改函数或方法的行为。而当我们谈论“属性装饰器”时,则是在探讨如何使用装饰器来增强类中属性的功能。这不仅让我们的代码更加简洁、易读,同时也提供了强大的功能扩展能力。本文将带你深入了解属性装饰器的核心概念,并通过一系列实例展示其在不同场景下的应用,从基础到进阶,再到实际项目的实战经验分享,帮助你解锁Python编程

react笔记 8-17 属性绑定 class绑定 引入图片 循环遍历

1、绑定属性 constructor(){super()this.state={name:"张三",title:'我是一个title'}}render() {return (<div><div>aaaaaaa{this.state.name}<div title={this.state.title}>我是一个title</div></div></div>)} 绑定属性直接使用花括号{}   注

ConstraintLayout布局里的一个属性app:layout_constraintDimensionRatio

ConstraintLayout 这是一个约束布局,可以尽可能的减少布局的嵌套。有一个属性特别好用,可以用来动态限制宽或者高app:layout_constraintDimensionRatio 关于app:layout_constraintDimensionRatio参数 app:layout_constraintDimensionRatio=“h,1:1” 表示高度height是动态变化

Python中的私有属性与方法:解锁面向对象编程的秘密

在Python的广阔世界里,面向对象编程(OOP)是一种强大而灵活的方法论,它帮助我们更好地组织代码、管理状态,并构建可复用的软件组件。而在这个框架内,私有属性与方法则是实现封装的关键机制之一。它们不仅有助于隐藏类内部的具体实现细节,还能保护数据免受外部干扰。今天,让我们一起探索Python中私有属性与方法的魅力所在,了解它们如何在实际开发中发挥重要作用。 引言 随着软件系统变得越来越复杂,维

转:android ro.debuggable属性调试修改(mprop逆向)

android ro属性调试修改(mprop逆向)      大家都知道如果需要调试android 的程序,以下两个条件满足一个就行。第一是apk的配置文件内的AndroidManifest.xml的 android:debuggable=”true”,第二就是/default.prop中ro.debuggable=1。两种方式第一种通常是解包添加属性再打包,随着加壳软件以及apk校验等,容易出