I am having an issue with my application. I recently added ScrollView as the Parent of LinearLayout. When flip my device orientation to Landscape, my buttons get cut off on the top. I can see the last button just fine with extra "black space" at the end of it when I scroll down, only the top gets cut off. I looked around and I am not sure why this is happening. Here are some pictures so you can understand how it looks.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center_vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<Button
android:id="@+id/BeefButton"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center"
android:background="@drawable/backgroundlayer"
android:drawableLeft="@drawable/beefbutton"
android:text="Beef"
android:textColor="#FFFFFF"
android:textSize="32px"
android:textColorHighlight="#FF6600"/>
<Button
android:id="@+id/PoultryButton"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_width="match_parent"
android:background="@drawable/backgroundlayer"
android:drawableLeft="@drawable/chickenbutton"
android:text="Poultry"
android:textColor="#FFFFFF"
android:textSize="32px"
android:textColorHighlight="#FF6600"/>
<Button
android:id="@+id/FishButton"
android:layout_height="wrap_content"
android:background="@drawable/backgroundlayer"
android:drawableLeft="@drawable/fishbutton"
android:text="Fish"
android:textColor="#FFFFFF"
android:textSize="32px"
android:textColorHighlight="#FF6600"
android:layout_gravity="center"
android:layout_width="match_parent"/>
<Button
android:id="@+id/PorkButton"
android:layout_height="wrap_content"
android:background="@drawable/backgroundlayer"
android:drawableLeft="@drawable/porkbutton"
android:text="Pork"
android:textColor="#FFFFFF"
android:textSize="32px"
android:textColorHighlight="#FF6600"
android:layout_gravity="center"
android:layout_width="match_parent"/>
<Button
android:id="@+id/VegetablesButton"
android:layout_height="wrap_content"
android:background="@drawable/backgroundlayer"
android:drawableLeft="@drawable/vegetablesbutton"
android:text="Vegetables"
android:textColor="#FFFFFF"
android:textSize="32px"
android:textColorHighlight="#FF6600"
android:layout_gravity="center"
android:layout_width="match_parent"/>
</LinearLayout>
</ScrollView>
remove the android:layout_gravity="center"
on your linearlayout , when you change it to landscape mode the height of the scrollview is bigger than your screen size, so its centering the linearlayout in the ScrollView, although removing it may not be the solution, that is what is causing this,
you may consider revising your layout, it might make more sense to use a listview to be able to successfully support landscape
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With