В моем приложении я вставляю пары прядильщиков в линейный режим, который находится внутри прокрутки. Проблема в том, что, когда я добавляю достаточно прядильщиков, две верхние части частично скрыты. Вот что я говорю.Вид сверху в LinearLayout, встроенный в ScrollView, только наполовину видимый
<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
Я не понимаю вопроса ... вы вкладываете слишком много, чтобы соответствовать. Прокрутите так, чтобы отображались те, которые вы хотите. Что еще вы ожидаете от этого? – Barak
thats, потому что вы устанавливаете высоту прокрутки в «match_parent» вместо «wrap_content» ... и точно так же, как комментарий .. не очень хорошая идея иметь «пустой» textView просто оставить некоторое пространство между двумя элементами try используя атрибут Gravity. – Raykud
Барак, он не прокручивается дальше. –