开发者

Android Layout won't scroll vertically in landscape orientation

Hi Stack Overflow Community,

I'm hoping you can help with an Android layout issue I'm having. I can't seem to get my activity to scroll vertically when I have it in landscape orientation.

I have a scrollview parent and a relativelayout child. Inside the relativelayout I have my various elements. Portrait orientation looks great but in landscape the imageview I have shrinks to fit everything in the screen verus having a vertical scroll which I want.

Any help is always greatly appreciated and code on!

-AmarettoSlim

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView"
    android:layout_height="fill_parent" android:layout_width="fill_parent" android:fillViewport="true" android:scrollbars="vertical">

    <RelativeLayout android:id="@+id/MainScreen" android:background="@color/appbackground" android:layout_width="fill_parent" android:layout_height="fill_parent" android:isScrollContainer="true" android:scrollbars="vertical" android:scrollbarStyle="insideOverlay">
        <Spinner android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignLeft="@+id/cspinner" android:layout_marginTop="48dp" android:id="@+id/pspinner" android:layout_above="@+id/buttonGo"></Spinner>
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/cspinner" android:layout_toLeftOf="@+id/cspinner" android:layout_marginRight="14dp" android:layout_marginTop="14dp" android:id="@+id/labelC" android:text="@string/lblC"></TextView>
        <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/logo" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="14dp" android:id="@+id/bannerLogo"></ImageView>
        <TextView android:id="@+id/labelPrice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/lblP" android:layout_alignTop="@+id/pspinner" android:layout_alignRight="@+id/labelC" android:layout_开发者_运维百科marginTop="16dp"></TextView>
        <Spinner android:layout_height="wrap_content" android:id="@+id/cspinner" android:layout_width="wrap_content" android:layout_above="@+id/labelP" android:layout_centerHorizontal="true"></Spinner>
        <ImageView android:layout_height="wrap_content" android:id="@+id/imgHat" android:layout_width="wrap_content" android:src="@drawable/bowlericon" android:layout_centerHorizontal="true" android:layout_below="@+id/bannerLogo" android:layout_above="@+id/cspinner"></ImageView>
        <Button android:id="@+id/buttonGo" android:layout_width="fill_parent" android:text="@string/btnRun" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true"></Button>
    </RelativeLayout>

</ScrollView>


try making a separate layout for landscape mode and putting it into

res/layout-land/


Hmm... You give an important clue: "In LandScape everything shrinks to fit". If everything fits, it's normal there's no scroll!

So I'd suggest to change your RelativeLayout height to "wrap content" instead of "fill parent". That way, if the contents inside your relativelayout exceed the scrollview height, you will be able to scroll.

BTW- Besides, fill parent is now obsolete. You should be using "match parent" instead!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜