Другой способ решить эту проблему - через xml.
Хитрость заключается в том, чтобы добавить "Виды пространств" в качестве дочерних элементов HorizontalScrollView и установить для них ширинусмещение, которое вы хотите получить.
Пример:
<!--BUTTONS ON HORIZONAL SCROLL -->
<HorizontalScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/scroll_view_child_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- This View does the trick! -->
<Space
android:layout_width="16dp"
android:layout_height="match_parent" />
<Button
android:id="@+id/btn_1"
style="@style/HorizontalScrollButtons"
android:text="Btn1" />
<Button
android:id="@+id/btn_2"
style="@style/HorizontalScrollButtons"
android:text="Btn1" />
<!-- Keep adding buttons... -->
<!-- This View does the trick too! -->
<Space
android:layout_width="16dp"
android:layout_height="match_parent" />
</LinearLayout>
</HorizontalScrollView>
В этом примере я хочу "запас" на 16 дп, поэтому я даю Пробел Просмотр ширина из 16dp.
Это даст это ... ![The way we want](https://i.stack.imgur.com/tW6S3.png)
... вместо этого ... ![enter image description here](https://i.stack.imgur.com/oOyrJ.png)
... в качестве начального вида.