androi

来源:互联网 发布:62078端口 编辑:程序博客网 时间:2024/05/01 08:28

这几天没事做了一个简单的菜单布局,在这里我没有添加任何的功能只是做了一个简单的布局。看着还可以,就想着与大家分享一下。

代码如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:background="@drawable/beijing" >


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="25dp"
            android:orientation="vertical" >


            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="5dp"
                android:layout_marginLeft="5dp"
                android:src="@drawable/ic_launcher" />
            
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="微信"
                android:textSize="10sp"
                android:layout_marginLeft="12dp"/>


        </LinearLayout>


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="35dp"
            android:layout_marginTop="4dp"
            android:orientation="vertical" >


            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:src="@drawable/ic_launcher" />


            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:text="通讯录"
                android:textSize="10sp" />
        </LinearLayout>


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="35dp"
            android:orientation="vertical" >


            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="5dp"
                android:layout_marginLeft="5dp"
                android:src="@drawable/ic_launcher" />


            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="发现" 
                android:textSize="10sp"
                android:layout_marginLeft="12dp"/>


        </LinearLayout>


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="35dp"
            android:orientation="vertical" >


            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="5dp"
                android:layout_marginLeft="5dp"
                android:src="@drawable/ic_launcher" />


            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="10sp"
                android:layout_marginLeft="14dp"
                android:text="我" />


        </LinearLayout>


    </LinearLayout>


</LinearLayout>

说明:在这里主要练习的是空间之间的布局。还有就是空间之间是如何跟好的联系起来的。

1、首先用LinearLayout进行分块,使得将整个的布局,变成一个一个使用的块,然后就是添加控件了,ImageView使图片视图控件,TextView是文字视图控件。

是由一个图片控件和一个文字视图控件组成的,并且在一个LinearLayout里面。

          效果图如下:

                                                                  :

1 0