1

Horizo​​ntalScrollView 内に 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

4

2 に答える 2

0

smoothScrollTo(x,y)画像が正しい位置にロックされているように見えるように使用する必要があります。X と Y は手動で計算する必要があります。

于 2012-11-21T10:41:51.837 に答える