zoukankan      html  css  js  c++  java
  • HorizontalScrollView水平滚动控件

       一、HorizontalScrollView控件只是支持水平滚动,而且它只能包含一个控件,通常是在< HorizontalScrollView >标签中定义了一个<LinearLayout>

    标签并且在<LinearLayout>标签中android:orientation属性值设置为horizontal,然后在<LinearLayout>标签中放置多个控件,如果<LinearLayout>标签中的控件所占用的总宽度超出屏幕的宽度,就会出现滚动效果
      二、下面是实例:
    在main.xml文件中:
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="fill_parent" android:layout_height="wrap_content">
     4 
     5     <LinearLayout android:orientation="horizontal"
     6         android:layout_width="fill_parent" android:layout_height="fill_parent">
     7 
     8         <ImageView android:layout_width="wrap_content"
     9             android:layout_height="wrap_content" android:src="@drawable/item1"></ImageView>
    10         <ImageView android:layout_width="wrap_content"
    11             android:layout_height="wrap_content" android:src="@drawable/item2"></ImageView>
    12 
    13         <ImageView android:layout_width="wrap_content"
    14             android:layout_height="wrap_content" android:src="@drawable/item3"></ImageView>
    15 
    16         <ImageView android:layout_width="wrap_content"
    17             android:layout_height="wrap_content" android:src="@drawable/item4"></ImageView>
    18 
    19         <ImageView android:layout_width="wrap_content"
    20             android:layout_height="wrap_content" android:src="@drawable/item5"></ImageView>
    21     </LinearLayout>
    22 </HorizontalScrollView>

    .java文件没有加入代码.

    运行结果:

    注意:水平方向出现滑动条

  • 相关阅读:
    CentOS 7.4 发布下载,安全稳定的Linux发行版
    PHP缓存机制详解
    用FastDFS一步步搭建文件管理系统
    linux中mv命令使用详解
    linux grep命令详解
    音频放大器的设计
    C#学习笔记(九)——集合、比较和转换
    Kinect学习笔记(五)——更专业的深度图
    C#学习笔记(八)——定义类的成员
    kinect学习笔记(四)——各种数据流
  • 原文地址:https://www.cnblogs.com/SoulCode/p/5405990.html
Copyright © 2011-2022 走看看