Ich möchte eine horizontale ScrollView machen, aber es zeigt nur 1 Bild und andere Bilder ist ausblenden, aber wenn vertikal ist Arbeit gut. Ich möchte es in Horizontal anzeigen und nicht ausblenden. dies ist mein xml-Code:Horizontale ScrollView funktioniert nicht in Android
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="110dp"
app:srcCompat="@mipmap/ic_launcher"
android:id="@+id/ivgallery"
tools:ignore="ContentDescription"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
app:srcCompat="@android:drawable/btn_dialog"
android:id="@+id/ivupload"
tools:ignore="ContentDescription"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:id="@+id/linearmain"/>
</ScrollView>
</LinearLayout>
und das ist mein Java-Code:
Bitmap bitmap = PhotoLoader.init().from(photopath).requestSize(512, 512).getBitmap();
final ImageView imageView = new ImageView(getApplicationContext());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(layoutParams);
imageView.setMaxWidth(250);
imageView.setMaxHeight(250);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(0, 10, 0, 0);
imageView.setAdjustViewBounds(true);
imageView.setImageBitmap(bitmap);
http://www.viralandroid.com/2015/11/android-horizontalscrollview-example.html –