HorizontalScrollView 内に LinearLayout があります。
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hsv"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/mygallery"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
LinearLayout では、次の方法で画像をロードします。
myGallery = (LinearLayout) findViewById(R.id.mygallery);
for (int i = 1; i <= 5; i++) {
ImageView iv = new ImageView(getApplicationContext());
iv.setLayoutParams(new LayoutParams(screenWidth,LayoutParams.WRAP_CONTENT));
iv.setImageBitmap(decodeSampledBitmapFromResource(getResources(),getResources().getIdentifier("pic0" + i, "drawable",getPackageName()), screenWidth, screenHeight));
myGallery.addView(iv);
ユーザーが画像をスクロールするとき、中央の画像をロックする必要があります(のようにGallery
)