学好安卓界面布局 实例图片上传篇

从学习安卓,我们知道Android中我们可以配置界面布局,那么今天和大家分享下界面布局的相关内容,界面布局主要分为LinearLayout (线性布局)AbsoluteLayout(绝对布局)RelativeLayout(相对布局)TableLayout(表格布局)FrameLayout(帧布局),其中绝对布局不是很常用,这里用实列给大家学习学习。http://www.xinyangzhuangshi.com/


很多学安卓的新手都会为怎么写好安卓的界面而烦恼 下面我会为大家写点项目实例上的界面

这里主要运用了LinearLayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#eee"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/layout_top"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:background="@drawable/public_top_bg" >

        <Button
            android:id="@+id/home_back"
            android:layout_width="45dp"
            android:layout_height="35dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="2dp"
            android:background="@drawable/public_top_ico"
            android:text="返回"
            android:textColor="@android:color/white" />

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="40dip"
            android:gravity="center" >

            <Button
                android:id="@+id/completeBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_marginTop="3dp"
                android:background="@drawable/public_top_ico"
                android:text="@string/completeStatisc"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/uploadPictureBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:layout_marginTop="3dp"
                android:layout_toRightOf="@id/completeBtn"
                android:background="@drawable/public_top_ico"
                android:text="@string/uploadPicture"
                android:textColor="@android:color/white" />
        </RelativeLayout>
    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/layout_top"
        android:background="@color/white"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/image_1"
                    android:layout_width="150dip"
                    android:layout_height="100dip"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:src="@drawable/ba" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:text="商户LOGO" />

                    <Button
                        android:layout_width="45dp"
                        android:layout_height="35dp"
                        android:layout_marginLeft="30dp"
                        android:background="@drawable/public_top_ico"
                        android:id="@+id/upload_1"
                        android:text="上传"
                        android:textColor="@color/white" />
                </LinearLayout>
            </LinearLayout>

            <TextView
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:background="@color/transparent" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/image_2"
                    android:layout_width="150dip"
                    android:layout_height="100dip"
                    android:src="@drawable/ba" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="0dp"
                      android:layout_marginRight="20dp"
                        android:text="营业照片" />

                    <Button
                        android:id="@+id/upload_2"
                        android:layout_width="45dp"
                        android:layout_height="35dp"
                        android:background="@drawable/public_top_ico"
                        android:layout_marginLeft="25dp"
                        android:text="上传"
                        android:textColor="@color/white" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
         <TextView
              android:layout_width="10dp"
              android:layout_height="10dp"
              android:background="@color/transparent" />
               <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/image_3"
                    android:layout_width="150dip"
                    android:layout_height="100dip"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:src="@drawable/ba" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:text="身份证正面" />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/red"
                        android:text="(必须)" />

                    <Button
                        android:id="@+id/upload_3"
                        android:layout_width="45dp"
                        android:layout_height="35dp"
                        android:background="@drawable/public_top_ico"
                        android:text="上传"
                        android:textColor="@color/white" />
                </LinearLayout>
            </LinearLayout>

            <TextView
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:background="@color/transparent" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/image_4"
                    android:layout_width="150dip"
                    android:layout_height="100dip"
                    android:src="@drawable/ba" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="0dp"
                        android:text="身份证反面" />
      <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/red"
                        android:text="(必须)" />
                    <Button
                        android:id="@+id/upload_4"
                        android:layout_width="45dp"
                        android:layout_height="35dp"
                        android:background="@drawable/public_top_ico"
                        android:text="上传"
                        android:textColor="@color/white" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
          <LinearLayout android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:orientation="horizontal"
             android:layout_marginTop="50dp"
             android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp">
          <Button  android:id="@+id/ensureBtn"
                android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:textColor="@android:color/white"
             android:text="@string/ensure"
             android:background="@drawable/public_top_ico"/>
      </LinearLayout>
    </LinearLayout>
 
</RelativeLayout>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值