【问题标题】:Android layout problem when using software keyboard使用软键盘时的Android布局问题
【发布时间】:2011-08-17 06:16:33
【问题描述】:

这是我正在使用的布局的简化版本:

<?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="5dp" 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>

问题在于,当单击 EditText 并显示键盘时,TextView 被向上推出屏幕。我希望 TextView 保持不变,并且 ScrollView 可以平移或调整大小。我已经在活动上尝试了 adjustPan 和 adjustResize (为了 UI 都可以)。 adjustResize 在我的 Gingerbread 设备上正常工作,但在我的 Froyo 设备上却不行。 adjustPan 对其中任何一个都不起作用。

【问题讨论】:

  • 由于某种原因 FrameLayout 的开始标签消失了,看起来像这样: schemas.android.com/apk/res/android" android:id="@+id/top_frame" android:layout_width= "fill_parent" android:layout_height="fill_parent" android:padding="0dp" android:background="#ffffff" android:isScrollContainer="false">

标签: android layout android-softkeyboard


【解决方案1】:

我建议你将根布局更改为RelativeLayout,并将TextView 固定在底部。然后让ScrollView从顶部展开到'TextView'。

【讨论】:

  • 这行得通,但会产生一些不同的结果。也许一个合适大小的容器用于固定在底部并覆盖在滚动视图上的文本视图。我将不得不对此进行更多试验。
猜你喜欢
  • 2017-06-13
  • 1970-01-01
  • 1970-01-01
  • 2011-10-17
  • 1970-01-01
  • 2016-04-20
  • 1970-01-01
  • 2011-10-09
  • 2012-08-28
相关资源
最近更新 更多