我正在尝试制作许多选项容器,其中包括2-10个选项。我想把这些选项放在一个容器中,该容器应该使选项居中,并使其垂直滚动,如下图所示。请帮忙。我怎么才能
ScrollView
元素彼此相邻。
Image:
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_black"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/filter_options"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible"
android:background="@color/secondary_color"
android:orientation="vertical">
<ScrollView
android:background="@color/light_black"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginTop="100dp">
<TextView
android:layout_width="150dp"
android:layout_height="fill_parent"
android:text="Option 1"
android:textAlignment="center"
android:textSize="28dp"
android:textColor="@color/white"
android:background="@color/green">
</TextView>
</ScrollView>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>