RelativeLayout相对布局各种常见的问题-创新互联

我是一个新手,刚开始接触android,我就今天学到的Relativelayout来和大家分享一下。

创新互联建站提供成都网站设计、做网站、网页设计,高端网站设计广告投放平台等致力于企业网站建设与公司网站制作,10年的网站开发和建站经验,助力企业信息化建设,成功案例突破超过千家,是您实现网站建设的好选择.


相对布局基本概念:一个控件的位置它决定于它和其他控件的关系,

好处:比较灵活;缺点:掌握比较复杂。

鉴于以上几点,所以要多进行练习,才能熟练掌握Relativelayout


Relativelayout常用属性;

子类控件相对子类控件:值是另外一个控件的id

android:layout_above----------位于给定DI控件之上

android:layout_below ----------位于给定DI控件之下

android:layout_toLeftOf -------位于给定控件左边

android:layout_toRightOf ------位于给定控件右边

android:layout_alignLeft -------左边与给定ID控件的左边对齐

android:layout_alignRight ------右边与给定ID控件的右边对齐

android:layout_alignTop -------上边与给定ID控件的上边对齐

android:layout_alignBottom ----底边与给定ID控件的底边对齐

android:layout_alignBaseline----对齐到控件基准线

相对父容器,值是true或false

android:layout_alignParentLeft ------相对于父靠左

android:layout_alignParentTop-------相对于父靠上

android:layout_alignParentRight------相对于父靠右

android:layout_alignParentBottom ---相对于父靠下

android:layout_centerInParent="true" -------相对于父即垂直又水平居中

android:layout_centerHorizontal="true" -----相对于父即水平居中

android:layout_centerVertical="true" --------相对于父即处置居中相对于父容器位置:

android:layout_margin="10dp"

android:layout_marginLeft

android:layout_marginRight

android:layout_marginTop

android:layout_marginBottom


相对布局的例子


  android:layout_width="fill_parent"

  android:layout_height="fill_parent">

  

    android:layout_width="100dp"

    android:layout_height="100dp"

    android:id="@+id/view1"

    android:background="@drawable/user"

    android:layout_centerInParent="true"

    />

  

    android:layout_width="100dp"

    android:layout_height="100dp"

    android:id="@+id/view2"

    android:background="@drawable/user"

    android:layout_above="@+id/view1"

    android:layout_alignLeft="@+id/view1"

    />

  

    android:layout_width="100dp"

    android:layout_height="100dp"

    android:id="@+id/view3"

    android:background="@drawable/user"

    android:layout_below="@+id/view1"

    android:layout_alignLeft="@+id/view1"

    />

  

    android:layout_width="100dp"

    android:layout_height="100dp"

    android:id="@+id/View4"

    android:background="@drawable/user"

    android:layout_toLeftOf="@+id/view1"

    android:layout_alignTop="@+id/view1"

    />

  

    android:layout_width="100dp"

    android:layout_height="100dp"

    android:id="@+id/view5"

    android:background="@drawable/user"

    android:layout_toRightOf="@+id/view1"

    android:layout_alignTop="@+id/view1">

RelativeLayout相对布局各种常见的问题

    

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


网页题目:RelativeLayout相对布局各种常见的问题-创新互联
URL分享:http://myzitong.com/article/djdopj.html