我有这个布局:
<HorizontalScrollView
android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/centro">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/welcometoflorida"
android:orientation="horizontal" >
<TextView
android:id="@+id/sf_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/southfloridacover" />
<TextView
android:id="@+id/cf_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/centralfloridacover" />
<TextView
android:id="@+id/nf_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/northfloridcover" />
<TextView
android:id="@+id/fb_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/floridabeaches" />
<TextView
android:id="@+id/tfry_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/ridescover" />
<TextView
android:id="@+id/sd_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/shoppingcover" />
<TextView
android:id="@+id/da_boton"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:background="@drawable/discovermapcover" />
</LinearLayout>
</HorizontalScrollView>
我希望当用户滚动视图时移动方式就像这两张图片一样。
我的滚动就像第一个视图,但是当我开始滚动时,只移动当前位置的项目。我想像第二张图片一样滚动。
答案 0 :(得分:0)
试试这个例子
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp"
android:scrollbars="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/twitter"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="256dp"
android:layout_toRightOf="@+id/facebook"
android:background="@android:color/transparent"
android:src="@drawable/twitterbirdicon500" />
<ImageButton
android:id="@+id/google"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_marginLeft="100dp"
android:layout_toRightOf="@+id/twitter"
android:background="@android:color/transparent"
android:src="@drawable/google500" />
<ImageButton
android:id="@+id/linkedin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="256dp"
android:layout_toRightOf="@+id/google"
android:background="@android:color/transparent"
android:src="@drawable/linkedin500" />
<ImageButton
android:id="@+id/facebook"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:src="@drawable/face500" />
</RelativeLayout>
</HorizontalScrollView>