水平卷轴布局HorizontalScrollLayout

public class

HorizontalScrollView

extends  FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.widget.HorizontalScrollView

类概述


用于布局的容器,可以放置让用户使用滚动条查看的视图层次结构,允许视图结构比手机的屏幕大. HorizontalScrollView 是一种 框架布局, 这意味着你可以将包含要滚动的完整内容的子视图放入该容器; 该子视图本身也可以是具有复杂层次结构的布局管理器.一般使用横向的 LinearLayout 作为子视图,使用户可以滚动其中显示的条目.

文本视图 类也有其自身的滚动处理,不需要嵌入滚动视图; 但二者可以组合使用,其效果与将文本视图放入很大容器中一样.

HorizontalScrollView 只支持水平方向的滚动。 For vertical scrolling, use either ScrollView or ListView.

实例:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="horizontal" 
	android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<HorizontalScrollView 
	    android:layout_height="wrap_content"
		android:layout_width="fill_parent"
		android:scrollbarAlwaysDrawHorizontalTrack="false">
		<LinearLayout 
		    android:id="@+id/LinearLayout02"
			android:layout_width="wrap_content" 
			android:orientation="horizontal"
			android:layout_height="fill_parent">
			<Button 
			    android:text="1" 
			    android:id="@+id/Button01"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
		    <Button android:text="2" 
		        android:id="@+id/Button02"
				android:layout_height="wrap_content" 
				android:layout_width="200px" />
		    <Button android:text="3" 
		        android:id="@+id/Button03"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
			<Button android:text="4" 
			    android:id="@+id/Button04"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
			<Button android:text="5" 
			    android:id="@+id/Button05"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
			<Button android:text="6" 
			    android:id="@+id/Button06"
				android:layout_height="wrap_content" 
				android:layout_width="200px" />
			<Button 
			    android:text="7" 
			    android:id="@+id/Button07"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
			<Button android:text="8" 
			    android:id="@+id/Button08"
				android:layout_width="200px" 
				android:layout_height="wrap_content" />
	    </LinearLayout>
	</HorizontalScrollView>


</LinearLayout>


package com.example.activity01;

import android.app.Activity;
import android.os.Bundle;

public class ScrollerActivity extends Activity {
	 @Override
	 protected void onCreate(Bundle savedInstanceState) {
	  // TODO Auto-generated method stub
	  super.onCreate(savedInstanceState);
	  setContentView(R.layout.main);
	 }
	}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值