随笔 - 632  文章 - 17  评论 - 54  阅读 - 93万

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   飘杨......  阅读(1443)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示