zoukankan      html  css  js  c++  java
  • Android常用布局

           <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView 
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:text="姓名:"
                />
            <EditText 
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                />
            <Button 
                android:layout_width="60dp" 
                android:layout_height="wrap_content"
                android:text="提交"
                />
        </LinearLayout>
    View Code

    左 中 右
    左右 长度固定

    设置中间的  android:layout_weight="1" 表示,左右填充完后,剩余的由中间填充

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="消息:" />
    
                <EditText
                    android:id="@+id/txtMsg"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="定时" />
    
                <TimePicker
                    android:id="@+id/txtWaringTime"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="图片" />
    
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/leaf" />
    
                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="80dp"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_launcher" />
       
            </LinearLayout>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="创建时间" />
    
                <EditText
                    android:id="@+id/txtAddTime"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="最近执行" />
    
                <EditText
                    android:id="@+id/txtLastActTime"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="最近提醒" />
    
                <EditText
                    android:id="@+id/txtLastNotifyTime"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="GUID" />
    
                <EditText
                    android:id="@+id/txtGID"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="今天忽略" />
    
                <EditText
                    android:id="@+id/txtLastIgnoreTime"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
    
                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="属性" />
    
                <CheckBox
                    android:id="@+id/chkInUse"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="启用" />
    
                <CheckBox
                    android:id="@+id/chkUseNotifyServer"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="使用提醒服务" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:orientation="horizontal" >
    
                <Button
                    android:id="@+id/btnSetIgnore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="今天忽略" />
    
                <Button
                    android:id="@+id/btnSave"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="保存记录" />
    
                <Button
                    android:id="@+id/btnDel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="删除" />
    
                <Button
                    android:id="@+id/btnBack"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="退出  " />
            </LinearLayout>
        </LinearLayout>
    
    </ScrollView>
    View Code

    带滚动条的布局,ScrollView直接包含元素只允许一个,但是非直接包含元素可以多个

  • 相关阅读:
    利用NPOI导出数据到Execl
    分享微信开发Html5轻游戏中的几个坑
    Integrate non-OSGi Dependencies
    Websocket Component
    ServiceMix in daemon mode
    springboot jwt配置(更新中)
    npm run build 后的dist文件,发布到web服务。
    不重复随机数列的生成算法 Leetcode 384. Shuffle an Array
    LSM树-HBASE为什么快
    混沌工程初探
  • 原文地址:https://www.cnblogs.com/wdfrog/p/3283148.html
Copyright © 2011-2022 走看看