【发布时间】:2015-05-31 04:30:29
【问题描述】:
上面是我的应用程序中的“详细信息”线性布局。正如您所看到的,微调器似乎比“Level 1”和“Per Level”下降得更多。我已经弄乱了 xml 以尝试将所有内容都放在一个共同的基础上,而不会使微调器掉下来,但我就是想不通。我尝试将微调器高度设置为“fill_parent”,它确实在同一基线上,但微调器内没有显示任何文本。有没有人知道该怎么做?
它们所在布局的 XML:
<LinearLayout
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal" >
<TextView
android:id="@+id/blank"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2" />
<TextView
android:id="@+id/levelOne"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/level_1" />
<TextView
android:id="@+id/perLevel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/per_level" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
这是我在微调器内的文本的 XML:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp">
</TextView>
我在我的班级中使用它来填充我想要的文本大小:
spinLevels = (Spinner) view.findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.LevelChosen, R.layout.spinner_item);
spinLevels.setAdapter(adapter);
【问题讨论】:
标签: android xml layout spinner