Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Landscape mode cutting off my buttons on top

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>
like image 481
SickNick Avatar asked Dec 17 '10 18:12

SickNick


1 Answers

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

like image 164
slim Avatar answered Sep 17 '22 03:09

slim