Jaytjuh
Jaytjuh

Reputation: 1083

How to adjustPan only one view?

I have a scrolling background that doesnt work correctly when the software keyboard is on the screen, so I've put android:windowSoftInputMode="adjustPan" in the manifest.

This prevents the scrolling background from breaking down, but it also prevents the rest of the screen from resizing so filling out the input fields becomes anoying.

Is there a way to apply android:windowSoftInputMode="adjustPan" only on the horizontalscrollview?

<HorizontalScrollView 
    android:id="@+id/scrollingbackground"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/bg_image"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/background_loop"
            android:adjustViewBounds="true"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/background_loop"
            android:adjustViewBounds="true"/>
    </LinearLayout>
</HorizontalScrollView>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
//the input fields

Upvotes: 2

Views: 1183

Answers (1)

Jaytjuh
Jaytjuh

Reputation: 1083

I've just put an extra linearlayout at the bottom of the scrollview and sized it programmaticly 50% of the height of the screen. So when I use android:windowSoftInputMode="adjustPan" now I can still scroll down enough to see all the elements in the scrollview.

Not the cleanest solution IMO, but it'll do for now.

Upvotes: 1

Related Questions