【问题标题】:Push view above when using custom Keyboard使用自定义键盘时推送上面的视图
【发布时间】:2014-07-03 13:23:36
【问题描述】:

我为我的 android 应用程序创建了一个自定义键盘。我还禁用了默认的 android 键盘。我将键盘显示为 Activity 中的片段,它显示得很好。

只有当键盘出现时,我才无法将活动视图推到上方。有什么办法可以做到吗?

XML 文件

<FrameLayout
        android:id="@+id/flKeyboard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

显示片段

FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(R.id.flKeyboard, new Keyboard()).commit();

【问题讨论】:

  • 我不确定你的意思。键盘在屏幕顶部吗?还是像图层一样在您的活动视图下?
  • 它在顶部。我在 xml 文件中添加了 FrameLayout,并在需要时添加了键盘片段。

标签: android view keyboard push


【解决方案1】:

你可以试试这样的:

<RelativeLayout>  
<View
    android:id="@+id/myView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
 />  
<FrameLayout
        android:id="@+id/flKeyboard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/myView"
/>

</RelativeLayout>

【讨论】:

  • 不起作用。它在视图下方显示键盘,但不会向上推视图。所以,我只能看到一行键盘
  • 也试过了。它不会推动上面的视图,只是让它更小更扁。
【解决方案2】:

我不确定这是否正确,但我使用了平移动画来沿 Y 轴移动视图。通过一些调整,它实际上看起来比默认的 android push 更好。

【讨论】:

    猜你喜欢
    • 2013-05-23
    • 2016-04-04
    • 2017-04-20
    • 1970-01-01
    • 2016-10-16
    • 2014-10-18
    • 1970-01-01
    • 1970-01-01
    • 2017-10-04
    相关资源
    最近更新 更多