简体   繁体   中英

ScrollView Android with images

I want to put three images on a vertical scroll view, I don't know why, but I just see the third one ( tuto3 ).

here is the xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView" >

        <LinearLayout
            android:id="@+id/linearLayout42"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </LinearLayout>

    </ScrollView>

</LinearLayout>

And there the class:

public class about extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aboutlayout);
        LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayout42);
        ImageView image = new ImageView(about.this);
        image.setBackgroundResource(R.drawable.tuto1);
        ll.addView(image);
        ImageView image2 = new ImageView(about.this);
        image.setBackgroundResource(R.drawable.tuto2);
        ll.addView(image2);
        ImageView image3 = new ImageView(about.this);
        image.setBackgroundResource(R.drawable.tuto3);
        ll.addView(image3);
    }
}

您继续在image而不是imageimage1image2上调用setBackgroundResource。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM