布局管理器 5-----绝对布局
生活随笔
收集整理的這篇文章主要介紹了
布局管理器 5-----绝对布局
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
絕對布局由AbsoluteLayout代表。絕對布局就像java AWT編程中的空布局,就是Android不提供任何布局控制而是由開發人員自己通過X坐標、Y坐標來控制組件的位置。當使用AbsoluteLayout作為布局容器時,布局容器不再管理子組件的位置、大小---這些都需要開發人員自己控制。
使用絕對布局是,每個組件都可指定如下兩個XML屬性
layout_x:指定該組件的X坐標
layout_y:指定該組件的Y坐標
例子:登錄界面
main.xml代碼
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><!-- 定義一個文本框,使用絕對定位 --><TextView android:layout_x="20dip"android:layout_y="20dip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="用戶名:"/><!-- 定義一個文本編輯框,使用絕對定位 --><EditText android:layout_x="80dip"android:layout_y="15dip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="200px"/><!-- 定義一個文本框,使用絕對定位 --><TextView android:layout_x="20dip"android:layout_y="80dip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密碼:"/><!-- 定義一個文本編輯框,使用絕對定位 --><EditText android:layout_x="80dip"android:layout_y="75dip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="200px"android:password="true"/><!-- 定義一個按鈕,使用絕對定位 --><Button android:layout_x="130dip"android:layout_y="135dip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="登錄"/> </AbsoluteLayout>java 代碼:
package com.nuaa.absolutelayout;import android.app.Activity; import android.os.Bundle;public class AbsoluteLayoutTest extends Activity {public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);}}?
轉載于:https://my.oschina.net/jintiangufei/blog/88300
總結
以上是生活随笔為你收集整理的布局管理器 5-----绝对布局的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sharepoint Caml查询中时间
- 下一篇: CMS:文章管理之视图(2)