调查队网站建设,erp系统软件功能介绍,网站还没上线 可以对网站备案吗,网站 建设开发合同04 Android基础--RelativeLayout什么是RelativeLayout#xff1f;RelativeLayout的常见用法#xff1a;什么是RelativeLayout#xff1f; 相对布局#xff08;RelativeLayout#xff09;是一种根据父容器和兄弟控件作为参照来确定控件位置的布局方式。 根据父容器定位 在相…
04 Android基础--RelativeLayout什么是RelativeLayoutRelativeLayout的常见用法什么是RelativeLayout 相对布局RelativeLayout是一种根据父容器和兄弟控件作为参照来确定控件位置的布局方式。 根据父容器定位 在相对布局中可以通过以下的属性让的组合让控件处于父容器左上角、右上角、左下角、右下角、上下左右居中正居中等九个位置。属性如下
android:layout_alignParentLeft“true” 父容器左边android:layout_alignParentRight“true” 父容器右边android:layout_alignParentTop“true” 父容器顶部android:layout_alignParentBottom“true” 父容器底部android:layout_centerHorizontal“true” 水平方向居中android:layout_centerVertical“true” 垂直方向居中android:layout_centerInParent“true” 水平垂直都居中 根据兄弟控件定位 在相对布局中还支持通过已确定位置的控件作为参考来确定其他控件的位置以下的属性让的组合让控件处于另外控件左上角、右上角、左下角、右下角、正上方、正下方、正左方、正右方等位置。属性如下
android:layout_toLeftOf“id/button1” 在button1控件左方android:layout_toRightOf“id/button1” 在button1控件右方android:layout_above“id/button1” 在button1控件上方android:layout_below“id/button1” 在button1控件下方android:layout_alignLeft“id/button1” 与button1控件左边平齐android:layout_alignRight“id/button1” 与button1控件右边平齐android:layout_alignTop“id/button1” 与button1控件上边平齐android:layout_alignBottom“id/button1” 与button1控件下边平齐 RelativeLayout的常见用法
第一种情况常用的列表页布局 RelativeLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent// 标题includeandroid:idid/title_layoutlayoutlayout/title_layout/// 1.android:layout_belowid/title_layout这个布局在title的下方// 2.android:layout_marginBottom60dp指定该属性所在控件距下部最近控件的最小值androidx.swiperefreshlayout.widget.SwipeRefreshLayoutandroid:idid/sw_layoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_belowid/title_layoutandroid:layout_marginBottom60dpandroidx.recyclerview.widget.RecyclerViewandroid:idid/recyclerviewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent //androidx.swiperefreshlayout.widget.SwipeRefreshLayout// 3.android:layout_alignParentBottomtrue在父容器底部LinearLayoutandroid:layout_alignParentBottomtrueButtonandroid:idid/material_applyandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent//LinearLayout/RelativeLayout第二种情况常用的搜索抽屉布局 搜索栏有很多有滚动条重置与搜索按钮在最底部。 RelativeLayout// 1. 添加滚动条androidx.core.widget.NestedScrollViewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingHorizontal20dp// 2. 搜索栏需要 占满全屏 LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewstylestyle/select_titleandroid:textstring/material_type /androidx.recyclerview.widget.RecyclerViewandroid:idid/madetails_recyclerviewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginTop20dp /TextViewstylestyle/select_titleandroid:layout_marginTop20dpandroid:textstring/name_of_goods /EditTextandroid:idid/madetails_name_of_goodsstylestyle/select_edandroid:backgrounddrawable/select_ed_backgroundandroid:hintstring/name_of_goods /TextViewstylestyle/select_titleandroid:layout_marginTop20dpandroid:textstring/model_of_goods /EditTextandroid:idid/madetails_model_of_goodsstylestyle/select_edandroid:backgrounddrawable/select_ed_backgroundandroid:hintstring/model_of_goods /TextViewstylestyle/select_titleandroid:layout_marginTop20dpandroid:textstring/specification_of_goods /EditTextandroid:idid/madetails_specification_of_goodsstylestyle/select_edandroid:backgrounddrawable/select_ed_backgroundandroid:hintstring/specification_of_goods /TextViewstylestyle/select_titleandroid:layout_marginTop20dpandroid:textstring/code_of_goods /EditTextandroid:idid/madetails_code_of_goodsstylestyle/select_edandroid:backgrounddrawable/select_ed_backgroundandroid:hintstring/code_of_goods //LinearLayout/androidx.core.widget.NestedScrollView// 3. android:layout_alignParentBottomtrue相对于根元素布局在根元素的底部。LinearLayoutstylestyle/select_bottom_layoutandroid:layout_alignParentBottomtrueButtonandroid:idid/reset_btnandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight2android:backgroundcolor/dark_blueandroid:textstring/resetandroid:textColorcolor/whiteandroid:textSize22dp /Buttonandroid:idid/filter_btnandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight3android:backgroundcolor/colorAccentandroid:textstring/filterandroid:textColorcolor/whiteandroid:textSize22dp //LinearLayout/RelativeLayout类似于这种布局的做法1.上面的元素需要占满全屏 2.下面的按钮 android:layout_alignParentBottomtrue 相对父元素布局在父元素的底部。 第三种情况子页面展示项
?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:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationvertical!--1. android:layout_alignParentLefttrue: 父容器左边android:layout_alignParentRighttrue 父容器右边android:layout_centerInParenttrue 水平垂直都居中--RelativeLayout android:layout_widthmatch_parentandroid:layout_height60pxTextViewandroid:layout_alignParentLefttrueandroid:layout_centerInParenttrueandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text测试 /TextViewandroid:idid/apply_form_tvandroid:layout_alignParentRighttrueandroid:layout_centerInParenttrueandroid:layout_widthwrap_contentandroid:layout_heightwrap_contenttools:text测试 //RelativeLayout!--测试--RelativeLayout stylestyle/sub_lineTextViewandroid:layout_alignParentLefttrueandroid:layout_centerInParenttrueandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text测试 /TextViewandroid:idid/apply_form_tvandroid:layout_alignParentRighttrueandroid:layout_centerInParenttrueandroid:layout_widthwrap_contentandroid:layout_heightwrap_contenttools:text测试 //RelativeLayout/LinearLayout/RelativeLayout对于这种展示形布局或者说是提交型布局1.LinearLayout 标签可以让其下的子布局页面竖向排列 2.RelativeLayout 标签位于父容器左边与父容器右边且水平竖直居中。