android 制作横向滑动菜单

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent"
         >
   <LinearLayout 
       android:orientation="horizontal"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       >
       <ImageView 
           android:id="@+id/menu_imgv1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/ic_launcher"/>
        <ImageView 
           android:id="@+id/menu_imgv2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/ic_launcher"/>

   </LinearLayout>
     <ListView android:id="@id/android:list"
               android:layout_width="fill_parent" 
               android:layout_height="fill_parent"
               android:background="#00FF00"
               
               android:layout_weight="1"
               android:drawSelectorOnTop="false"/>
  <HorizontalScrollView 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none"
            >
           <LinearLayout 
               android:id="@+id/linearLayout"
               android:orientation="horizontal"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               >
              
                <ImageView 
                   android:id="@+id/menu_imgv3"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                 <ImageView 
                   android:id="@+id/menu_imgv4"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  <ImageView 
                   android:id="@+id/menu_imgv5"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  <ImageView 
                   android:id="@+id/menu_imgv6"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                 <ImageView 
                   android:id="@+id/menu_imgv7"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  <ImageView 
                   android:id="@+id/menu_imgv8"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  <ImageView 
                   android:id="@+id/menu_imgv9"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                 <ImageView 
                   android:id="@+id/menu_imgv10"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  <ImageView 
                   android:id="@+id/menu_imgv11"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="@drawable/ic_launcher"/>
                  
           </LinearLayout>  
   </HorizontalScrollView>
 </LinearLayout>

实现滑动的主要是HorizontalScrollView空间,它实现了横向滑动的功能。

备注:看到本例时只需要将代码复制到main.xml中然后运行程序查看效果

posted on 2012-09-13 16:56  飘杨......  阅读(1454)  评论(0)    收藏  举报