ScrollView只支持垂直滚动,所以要实现控件的水平拖动就要使用到HorizontalScrollView了。
隐藏白色边框方法:android:fillViewport="true" 和android:fadingEdge="none"。
隐藏滚动条方法:android:scrollbars="none"
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:fadingEdge="none">
<LinearLayout
android:id="@+id/linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/add"
android:onClick="addOnClick" />
</LinearLayout>
</HorizontalScrollView>