Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange margins in HorizontalScrollView

I need a list of view scrolled horizontally, so i've put LinearLayout in HorizontalScrollView and added elements to the LinearLayout. Everything is fine, but there is strange margins/padding(I don't know what it is)

This is the view fully scrolled to the left - first item is half aboard the parent

enter image description here

And this is the fully scrolled to the right one - strange padding on the right side

http://korniltsev.ru/m/gyazo/4d093939766fe.png

THis is my xml:

<HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <LinearLayout
                android:id="@+id/container"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"

                android:layout_gravity="center"/>
</HorizontalScrollView>

item:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="150dp"
                android:layout_height="match_parent"
        >

    <FrameLayout
            android:layout_width="140dp"
            android:layout_height="50dp"
            android:background="@drawable/bg_payment_system_item"
            android:layout_centerInParent="true"
            >
        <ImageView
                android:id="@+id/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                />
    </FrameLayout>
    <Button
        android:layout_width="30dp"
        android:layout_height="30dp"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"/>
</RelativeLayout>
like image 863
Korniltsev Anatoly Avatar asked Sep 14 '25 04:09

Korniltsev Anatoly


1 Answers

Ok so this behavior is an android bug. http://code.google.com/p/android/issues/detail?id=20088

like image 162
Korniltsev Anatoly Avatar answered Sep 15 '25 17:09

Korniltsev Anatoly