资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

android基础之RelativeLayout布局-创新互联

RelativeLayout布局

创新互联是一家专业提供瓜州企业网站建设,专注与成都网站设计、成都网站建设、H5建站、小程序制作等业务。10年已为瓜州众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

在相对布局中,至少要确定组件的“左右“ “上下” 两个位置才能准确固定组件位置

组件之间的位置关系:

android:layout_above

android:layout_above="@id/btn2"表示与id为btn2的组件的上边缘对齐

android:layout_below

android:layout_toLeftOf

android:layout_toRightOf

组件对齐方式:

android:layout_alignBaseline 将该组件放在指定id组件进行中心线对齐

android:layout_alignTop

android:layout_alignBottom

android:layout_alignLeft

android:layout_alignRight

当前组件与父组件的对齐方式:

android:layout_alignParentTop与父组件进行顶部对齐

android:layout_alignParentBottom

android:layout_alignParentLeft

android:layout_alignParentRight

组件放置位置:

android:layout_centerHorizontal放置在水平方向的中央位置

android:layout_centerVertical放置为垂直方向的中央位置

android:layout_centerInParent放置在父组件的水平中央及垂直中央的位置

以下代码示例:

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:paddingBottom="@dimen/activity_vertical_margin"

  android:paddingLeft="@dimen/activity_horizontal_margin"

  android:paddingRight="@dimen/activity_horizontal_margin"

  android:paddingTop="@dimen/activity_vertical_margin"

  tools:context=".MainActivity" >

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="Button1"

  android:id="@+id/btn1"

  />

  

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="Button2"

    android:id="@+id/btn2"

    android:layout_below="@id/btn1"

    />

  

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="Button3"

    android:id="@+id/btn3"

    android:layout_below="@id/btn2"

    android:layout_alignParentRight="true"

    />

   

     android:layout_width="wrap_content"

     android:layout_height="wrap_content"

     android:text="Button4"

     android:id="@+id/btn4"

     android:layout_below="@id/btn3"

     android:layout_alignParentRight="true"

     />

   

     android:layout_width="wrap_content"

     android:layout_height="wrap_content"

     android:text="Button5"

     android:id="@+id/btn5"

     android:layout_below="@id/btn4"

     android:layout_centerHorizontal="true"

     />

android基础之RelativeLayout布局


另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:android基础之RelativeLayout布局-创新互联
当前URL:http://cdkjz.cn/article/cceehh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220