日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

补13

發(fā)布時(shí)間:2025/4/5 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 补13 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

  • 相對(duì)布局RelativeLayout
  • 輸入姓名
    • 常見相對(duì)布局基本屬性:
    • 根據(jù)父容器定位
    • 根據(jù)兄弟組件定位
    • 4、填充(padding)
  • 創(chuàng)建安卓應(yīng)用
  • 編寫主布局資源文件
  • 運(yùn)行效果
  • 按鈕布局
  • 創(chuàng)建安卓應(yīng)用
  • 主布局資源文件
  • 運(yùn)行效果

相對(duì)布局RelativeLayout

輸入姓名

常見相對(duì)布局基本屬性:

  • gravity :設(shè)置該布局容器內(nèi)各子組件的對(duì)齊方式

  • ignoreGravity:設(shè)置哪個(gè)組件不受gravity屬性的影響

根據(jù)父容器定位

  • layout_alignParentLeft 左對(duì)齊
  • layout_alignParentRight 右對(duì)齊
  • layout_alignParentTop 頂部對(duì)齊
  • layout_centerVertical 垂直居中
  • layout_centerInparent 中間位置
  • layout_alignParentBottom 底部對(duì)齊

根據(jù)兄弟組件定位

  • android:layout_toLeftOf 參考組件的左邊

  • android:layout_toRightOf 參考組件的右邊

  • android:layout_above 參考組件的上方

  • android:layout_below 參考組件的下方

  • android:layout_alignTop 對(duì)齊參考組件的上邊界

  • android:layout_alignBottom 對(duì)齊參考組件的下邊界

  • android:layout_alignLeft 對(duì)齊參考組件的左邊界

  • android:layout_alignRight 對(duì)齊參考組件的右邊界

4、填充(padding)

  • android:padding 上下左右填充邊距

  • paddingLeft 左邊填充邊距

  • paddingRight 右邊填充邊距

  • paddingTop 上方填充邊距

  • paddingBottom 下方填充邊距

創(chuàng)建安卓應(yīng)用

編寫主布局資源文件

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><EditTextandroid:layout_width="150dp"android:layout_height="wrap_content"android:id="@+id/edtName"android:layout_alignParentTop="true"android:layout_alignParentRight="true"android:hint="請(qǐng)輸入姓名"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/tvName"android:text="姓名:"android:textSize="20dp"android:layout_alignBaseline="@+id/edtName"android:layout_toLeftOf="@+id/edtName"/><Buttonandroid:layout_width="60dp"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginTop="50dp"android:id="@+id/edtCancel"android:text="取消"/><Buttonandroid:id="@+id/edtOK"android:layout_width="60dp"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginTop="50dp"android:layout_marginRight="84dp"android:text="確定" /></RelativeLayout>

運(yùn)行效果

按鈕布局

創(chuàng)建安卓應(yīng)用

主布局資源文件

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="net.tp.relativelayoutdemo.MainActivity"><Buttonandroid:id="@+id/btn_center"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="中央" /><Buttonandroid:id="@+id/btn_upper_left"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toLeftOf="@id/btn_center"android:layout_above="@id/btn_center"android:text="左上"/><Buttonandroid:id="@+id/btn_upper_right"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/btn_center"android:layout_above="@id/btn_center"android:text="右上"/><Buttonandroid:id="@+id/btn_lower_left"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toLeftOf="@id/btn_center"android:layout_below="@id/btn_center"android:text="左下"/><Buttonandroid:id="@+id/btn_lower_right"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/btn_center"android:layout_below="@id/btn_center"android:text="右下"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_lower_left"android:layout_alignLeft="@id/btn_lower_left"android:layout_marginTop="15dp"android:text="確定"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_lower_right"android:layout_alignRight="@id/btn_lower_right"android:layout_marginTop="15dp"android:text="取消"/><Buttonandroid:id="@+id/btn_upper_left_corner"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:text="左上角"/><Buttonandroid:id="@+id/btn_upper_right_corner"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_alignParentTop="true"android:text="右上角"/><Buttonandroid:id="@+id/btn_lower_left_corner"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentBottom="true"android:text="左下角"/><Buttonandroid:id="@+id/btn_lower_right_corner"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_alignParentBottom="true"android:text="右下角"/></RelativeLayout>

運(yùn)行效果

總結(jié)

以上是生活随笔為你收集整理的补13的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。