在我的应用程序中,我将成对的微调器插入到滚动视图内的线性布局中。问题是,当我添加足够多的微调器时,前两个会被部分遮挡。这就是我要说的。
<LinearLayout
android:id="@+id/ChordHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:drawable/bottom_bar"
android:orientation="horizontal" >
<Button
android:id="@+id/addChordButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="Add Chord" />
<TextView
android:id="@+id/spacetext1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" "
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/removeChordButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="Remove Chord" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/ChordList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:isScrollContainer="true"
android:orientation="vertical"
android:weightSum="100" >
(微调器在这里插入)
</LinearLayout>
</ScrollView>
</LinearLayout>
如果有问题,这里是将微调器插入列表的代码。
Spinner chordName = new Spinner(this);
Spinner chordType = new Spinner(this);
LinearLayout container = new LinearLayout(this);
container.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout chordList = (LinearLayout) findViewById(R.id.ChordList);
chordName.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 80, 50));
chordName.setAdapter(nameAdapter);
container.addView(chordName); //add name spinner to container
chordType.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 80, 50));
chordType.setAdapter(typeAdapter);
container.addView(chordType); //add type spinner to container
container.setBackgroundResource(android.R.drawable.bottom_bar);
container.setPadding(10, 0, 10, 0);
chordList.addView(container); //add container to list layout