上面是我的應用程序中的「細節」線性佈局。正如你所看到的那樣,微調看起來更像「一級」和「每級」。我已經搞砸了xml,試圖讓所有的東西都在一個共同的基礎上,但是我不能弄明白。我試着將spinners高度設置爲「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);