У меня есть HorizontalScrollView, который динамически заполняется TextViews. Когда-то есть один, два, три или более элемента. То, что я ищу, - это способ центрирования элементов независимо от количества элементов.
Например, с одним элементом:
| --------- MenuA --------- |
С двумя элементами:
| ---- MenuA --- MenuB ---- |
С тремя элементами:
| - MenuA - MenuB - MenuC - |
С пятью элементами (MenuD и MenuE скрыты):
| MenuA - MenuB - MenuC - Me|
Обновление: вот простой макет с двумя меню. Как настроить CenterA и MenuB?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView android:text="MenuA" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:text="MenuB" android:id="@+id/textView2"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>