Reputation: 749
i want to make a Horizontal ScrollView but it show only 1 image and other images is hide but when is vertical is work good. i want it show in Horizontal and not hide. this is my xml code :
<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>
and this is my 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);
Upvotes: 0
Views: 2343
Reputation: 150
Try to use NestedScrollView
instead of scroll View
and enter add recyclerView.setNestedScrollingEnabled(false);
to your RecyclerView in java
Upvotes: 0
Reputation: 753
can you try this, change your element horizontal scrollview :
<package_name.HorizontalListView
android:id="@+id/hlvCustomList"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/add_image"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants" />
in your horizontal element, this is key of :
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants"
hope this will help you ;)
Upvotes: 0
Reputation: 1170
for horizontal scroll you will have to use HorizontalScrollView
so replace this
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal">
<LinearLayout
android:id="@+id/linearmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" />
</ScrollView>
with
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal">
<LinearLayout
android:id="@+id/linearmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" />
</HorizontalScrollView>
Upvotes: 1
Reputation: 12636
You should put your scrollable content into scroll view
favorite i want to make a Horizontal ScrollView but it show only 1 image and other images is hide but when is vertical is work good. i want it show in Horizontal and not hide. this is my xml code :
<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">
<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"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0
Reputation: 75788
You should use HorizontalScrollView
HorizontalScrollView only supports horizontal scrolling.For vertical scrolling, use either ScrollView or ListView.
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal">
<LinearLayout
android:id="@+id/linearmain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" />
</HorizontalScrollView>
Upvotes: 3
Reputation: 259
I thing your scrollview child means LinearLayout in that not anything
So please refer this link
[Link][1]
Link
Upvotes: 1