ANDROID: кнопки взвешенного линейного списка исчезают - PullRequest
1 голос
/ 03 февраля 2011

Я видел много сообщений об этом и перепробовал многие решения, но по какой-то причине ничего не работает.Я просто хочу, чтобы кнопки занимали одинаковое пространство ... Можете ли вы взглянуть на мой XML-код и посмотреть, если что-то не так?Спасибо!


    
        
        
        
        </p>

<code>    <ScrollView android:id="@+id/scrollview1"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:weightSum="120">
            <Button android:id="@+id/btn_mission" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Mission">
            </Button>
            <Button android:id="@+id/btn_news" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="News/Events">
            </Button>
            <Button android:id="@+id/btn_studentservices"
                android:layout_width="0dp" android:layout_height="wrap_content"
                android:background="#8D8BB7" android:layout_weight="20"
                android:text="Student Services">
            </Button>
            <Button android:id="@+id/btn_facultyservices"
                android:layout_width="0dp" android:layout_height="wrap_content"
                android:background="#8D8BB7" android:layout_weight="20"
                android:text="Faculty Services">
            </Button>
            <Button android:id="@+id/btn_staff" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Staff">
            </Button>
            <Button android:id="@+id/btn_library" android:layout_width="0dp"
                android:layout_height="wrap_content" android:background="#8D8BB7"
                android:layout_weight="20" android:text="Library">
            </Button>
        </LinearLayout>
    </ScrollView>
</LinearLayout>
</code>

РЕДАКТ.все еще должен прокрутить.

Ответы [ 2 ]

2 голосов
/ 03 февраля 2011

Попробуйте удалить android:weightSum="120" и установить android:layout_weight="20" на android:layout_weight="1" на всех кнопках.

1 голос
/ 03 февраля 2011

Ваш LinearLayout имеет вертикальную ориентацию, поэтому вместо android:layout_width="0dp" вы должны использовать android:layout_height="0dp".

...