Android layout problem when using software keyboard
Here is a simplified version of the layout I'm using:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/scroll_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbarStyle="insideOverlay" android:scrollbars="horizontal|vertical"
android:fadingEdgeLength="5d开发者_如何学Pythonp" android:fadingEdge="horizontal|vertical" android:isScrollContainer="true">
<AbsoluteLayout android:layout_width="1000dp" android:layout_height="1000dp" android:background="#ff3344">
<EditText android:text="test" android:layout_x="50dp" android:layout_y="800dp" android:layout_height="wrap_content" android:layout_width="wrap_content"></EditText>
</AbsoluteLayout>
</ScrollView>
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="top"
android:gravity="center" android:visibility="visible" android:text="Text View" android:textColor="#FFFFFF"/>
</FrameLayout>
The problem is that when the EditText is clicked and the keyboard is shown, the TextView gets pushed upwards out of the screen. I would like the TextView to stay put, and the ScrollView to either pan or resize. I have tried both adjustPan and adjustResize on the activity (either would be ok for the UI's sake). adjustResize WORKS correctly on my Gingerbread device, but not on my Froyo device. adjustPan doesn't work on either one of them.
I suggest you change the root layout to RelativeLayout
, and fix the TextView
to the bottom. Then let ScrollView
expand from top to the 'TextView'.
精彩评论