Кнопки в режиме прокрутки не отображается первая кнопка, когда в ландшафтном режиме в android

В моем приложении кнопки расположены в виде прокрутки, как в виде списка. это выглядит хорошо, когда, приложение в режиме портрета. когда я установил в ландшафтном режиме, первая кнопка не отображается. Заранее спасибо.

<ScrollView 
    android_id="@+id/scrollView1"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="@drawable/mm"

    >
    <LinearLayout
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        android_orientation="vertical"
        android_gravity="center_vertical|center_horizontal"
        android_layout_gravity="center_vertical|center_horizontal"
        >
    <LinearLayout
        android_layout_width="fill_parent"
        android_layout_height="fill_parent"
        android_orientation="vertical"
        android_layout_marginTop="15dp"
        android_layout_marginBottom="15dp"
        android_layout_marginLeft="15dp"
        android_layout_marginRight="15dp"
        android_gravity="center_vertical|center_horizontal"
        android_layout_gravity="center_vertical|center_horizontal"
        >


        <Button
            android_id="@+id/btn_milk_production"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_text="Milk Production"
            android_layout_margin="10dp"
            android_textSize="@dimen/button_txt_size"
            android_background="@drawable/btn"
            android_textColor="#1a1a1a"
            />

        <Button
            android_id="@+id/btn_milk_dispatch"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_text="Product Sales"
            android_layout_margin="10dp"
            android_textSize="@dimen/button_txt_size"
            android_background="@drawable/btn"
            android_textColor="#1a1a1a"
            />
        <Button
            android_id="@+id/btn_sale_order"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_text="sale order"
            android_layout_margin="10dp"
            android_textSize="@dimen/button_txt_size"
            android_background="@drawable/btn"
            android_textColor="#1a1a1a"
            />
        <Button
            android_id="@+id/btn_customer_creation"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_text="create customer"
            android_layout_margin="10dp"
            android_textSize="@dimen/button_txt_size"
            android_background="@drawable/btn"
            android_textColor="#1a1a1a"
            />
</LinearLayout>
</LinearLayout>
</ScrollView>

5 ответов

  1. попробовать это

    <ScrollView 
    android_id="@+id/scrollView1"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="@color/background"
    
    >
    <LinearLayout
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        android_orientation="vertical"
        android_gravity="center_vertical|center_horizontal"
        android_layout_gravity="center_vertical|center_horizontal"
        >
        <LinearLayout
            android_layout_width="fill_parent"
            android_layout_height="fill_parent"
            android_orientation="vertical"
            android_layout_marginTop="15dp"
            android_layout_marginBottom="15dp"
            android_layout_marginLeft="15dp"
            android_layout_marginRight="15dp"
            android_gravity="center_vertical|center_horizontal"
            android_layout_gravity="center_vertical|center_horizontal"
            >
    
    
            <Button
                android_id="@+id/btn_milk_production"
                android_layout_width="fill_parent"
                android_layout_height="wrap_content"
                android_text="Milk Production"
                android_layout_margin="10dp"
                android_textSize="25dp"
                android_background="@color/colorPrimary"
                android_textColor="#1a1a1a"
                />
    
            <Button
                android_id="@+id/btn_milk_dispatch"
                android_layout_width="fill_parent"
                android_layout_height="wrap_content"
                android_text="Product Sales"
                android_layout_margin="10dp"
                android_textSize="25dp"
                android_background="@color/colorPrimary"
                android_textColor="#1a1a1a"
                />
            <Button
                android_id="@+id/btn_sale_order"
                android_layout_width="fill_parent"
                android_layout_height="wrap_content"
                android_text="sale order"
                android_layout_margin="10dp"
                android_textSize="25dp"
                android_background="@color/colorPrimary"
                android_textColor="#1a1a1a"
                />
            <Button
                android_id="@+id/btn_customer_creation"
                android_layout_width="fill_parent"
                android_layout_height="wrap_content"
                android_text="create customer"
                android_layout_margin="10dp"
                android_textSize="25dp"
                android_background="@color/colorPrimary"
                android_textColor="#1a1a1a"
                />
        </LinearLayout>
        </LinearLayout>
         </ScrollView>
    

    выход макета

    Введите описание изображения здесь

  2. удалите следующее из макета

    android:gravity="center_vertical|center_horizontal"
    android_layout_gravity="center_vertical|center_horizontal"
    

    Это окончательный макет и его работа отлично для меня…
    (предполагаемая высота 120dp)

    <ScrollView 
        android_id="@+id/scrollView1"
        android_layout_width="fill_parent"
        android_layout_height="fill_parent"
        android_background="@drawable/mm"
    
        >
            <LinearLayout
                android_layout_width="fill_parent"
                android_layout_height="fill_parent"
                android_orientation="vertical"
                android_layout_marginTop="15dp"
                android_layout_marginBottom="15dp"
                android_layout_marginLeft="15dp"
                android_layout_marginRight="15dp"
                >
    
    
                <Button
                    android_id="@+id/btn_milk_production"
                    android_layout_width="fill_parent"
                    android_layout_height="120dp"
                    android_text="Milk Production"
                    android_layout_margin="10dp"
                    android_textSize="@dimen/button_txt_size"
                    android_background="@drawable/btn"
                    android_textColor="#1a1a1a"
                    />
    
                <Button
                    android_id="@+id/btn_milk_dispatch"
                    android_layout_width="fill_parent"
                    android_layout_height="120dp"
                    android_text="Product Sales"
                    android_layout_margin="10dp"
                    android_textSize="@dimen/button_txt_size"
                    android_background="@drawable/btn"
                    android_textColor="#1a1a1a"
                    />
                <Button
                    android_id="@+id/btn_sale_order"
                    android_layout_width="fill_parent"
                    android_layout_height="120dp"
                    android_text="sale order"
                    android_layout_margin="10dp"
                    android_textSize="@dimen/button_txt_size"
                    android_background="@drawable/btn"
                    android_textColor="#1a1a1a"
                    />
                <Button
                    android_id="@+id/btn_customer_creation"
                    android_layout_width="fill_parent"
                    android_layout_height="120dp"
                    android_text="create customer"
                    android_layout_margin="10dp"
                    android_textSize="@dimen/button_txt_size"
                    android_background="@drawable/btn"
                    android_textColor="#1a1a1a"
                    />
            </LinearLayout>
    
    </ScrollView>
    
  3. <ScrollView 
        android_id="@+id/scrollView1"
        android_layout_width="fill_parent"
        android_layout_height="fill_parent"
        android_background="@drawable/mm"
    
        >
        <LinearLayout
            android_layout_width="match_parent"
            android_layout_height="match_parent"
            android_orientation="vertical"
            android_gravity="center_vertical|center_horizontal"
            android_layout_gravity="center_vertical|center_horizontal"  <<-- remove this line
            >
        <LinearLayout
            android_layout_width="fill_parent"
            android_layout_height="fill_parent"
            android_orientation="vertical"
            android_layout_marginTop="15dp"
            android_layout_marginBottom="15dp"
            android_layout_marginLeft="15dp"
            android_layout_marginRight="15dp"
            android_gravity="center_vertical|center_horizontal"
            android_layout_gravity="center_vertical|center_horizontal"
            >
    
    
            <Button
                android_id="@+id/btn_milk_production"
                android_layout_width="fill_parent"
                android_layout_height="@dimen/button_layout_height"
                android_text="Milk Production"
                android_layout_margin="10dp"
                android_textSize="@dimen/button_txt_size"
                android_background="@drawable/btn"
                android_textColor="#1a1a1a"
                />
    
            <Button
                android_id="@+id/btn_milk_dispatch"
                android_layout_width="fill_parent"
                android_layout_height="@dimen/button_layout_height"
                android_text="Product Sales"
                android_layout_margin="10dp"
                android_textSize="@dimen/button_txt_size"
                android_background="@drawable/btn"
                android_textColor="#1a1a1a"
                />
            <Button
                android_id="@+id/btn_sale_order"
                android_layout_width="fill_parent"
                android_layout_height="@dimen/button_layout_height"
                android_text="sale order"
                android_layout_margin="10dp"
                android_textSize="@dimen/button_txt_size"
                android_background="@drawable/btn"
                android_textColor="#1a1a1a"
                />
            <Button
                android_id="@+id/btn_customer_creation"
                android_layout_width="fill_parent"
                android_layout_height="@dimen/button_layout_height"
                android_text="create customer"
                android_layout_margin="10dp"
                android_textSize="@dimen/button_txt_size"
                android_background="@drawable/btn"
                android_textColor="#1a1a1a"
                />
    </LinearLayout>
    </LinearLayout>
    </ScrollView>
    
  4. Удалите один тег LinearLayout из макета. В вашем случае это излишне.

        <ScrollView 
    android_id="@+id/scrollView1"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="@drawable/mm">
    
    <LinearLayout
        android_layout_width="fill_parent"
        android_layout_height="fill_parent"
        android_layout_gravity="center_vertical|center_horizontal"
        android_layout_marginBottom="15dp"
        android_layout_marginLeft="15dp"
        android_layout_marginRight="15dp"
        android_layout_marginTop="15dp"
        android_gravity="center_vertical|center_horizontal"
        android_orientation="vertical">
    
    
        <Button
            android_id="@+id/btn_milk_production"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_layout_margin="10dp"
            android_background="@drawable/btn"
            android_text="Milk Production"
            android_textColor="#1a1a1a"
            android_textSize="@dimen/button_txt_size" />
    
        <Button
            android_id="@+id/btn_milk_dispatch"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_layout_margin="10dp"
            android_background="@drawable/btn"
            android_text="Product Sales"
            android_textColor="#1a1a1a"
            android_textSize="@dimen/button_txt_size" />
    
        <Button
            android_id="@+id/btn_sale_order"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_layout_margin="10dp"
            android_background="@drawable/btn"
            android_text="sale order"
            android_textColor="#1a1a1a"
            android_textSize="@dimen/button_txt_size" />
    
        <Button
            android_id="@+id/btn_customer_creation"
            android_layout_width="fill_parent"
            android_layout_height="@dimen/button_layout_height"
            android_layout_margin="10dp"
            android_background="@drawable/btn"
            android_text="create customer"
            android_textColor="#1a1a1a"
            android_textSize="@dimen/button_txt_size" />
    </LinearLayout>
    </ScrollView>
    
  5. Try this...
    
    <ScrollView 
        android_id="@+id/scrollView1"
        android_layout_width="fill_parent"
        android_layout_height="fill_parent"
    
        >
            <LinearLayout
                android_layout_width="fill_parent"
                android_layout_height="fill_parent"
                android_orientation="vertical"
                android_layout_marginTop="15dp"
                android_layout_marginBottom="15dp"
                android_layout_marginLeft="15dp"
                android_layout_marginRight="15dp"
                >
    
                <Button
                    android_id="@+id/btn_milk_production"
                    android_layout_width="fill_parent"
                    android_layout_height="80dp"
                    android_text="Milk Production"
                    android_layout_margin="10dp"
                    android_textSize="15dp"
                    android_background="@null"
                    android_textColor="#1a1a1a"
                    />
    
                <Button
                    android_id="@+id/btn_sale_order"
                    android_layout_width="fill_parent"
                    android_layout_height="80dp"
                    android_text="sale order"
                    android_layout_margin="10dp"
                    android_textSize="15dp"
                    android_background="@null"
                    android_textColor="#1a1a1a"
                    />
    
                <Button
                    android_id="@+id/btn_milk_dispatch"
                    android_layout_width="fill_parent"
                    android_layout_height="80dp"
                    android_text="Product Sales"
                    android_layout_margin="10dp"
                    android_textSize="15dp"
                    android_background="@null"
                    android_textColor="#1a1a1a"
                    />
    
                <Button
                    android_id="@+id/btn_customer_creation"
                    android_layout_width="fill_parent"
                    android_layout_height="80dp"
                    android_text="create customer"
                    android_layout_margin="10dp"
                    android_textSize="15dp"
                    android_background="@null"
                    android_textColor="#1a1a1a"
                    />
            </LinearLayout>
    </ScrollView>