如何将布局放置在 android 屏幕键盘的正上方?

How can I position a layout right above the android on-screen keyboard?(如何将布局放置在 android 屏幕键盘的正上方?)
本文介绍了如何将布局放置在 android 屏幕键盘的正上方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

见附图.推特做得很好.他们有一个布局,由于没有更好的术语,我将其称为工具栏,就在屏幕键盘的正上方.如何使用我的代码执行此操作?

See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code?

更新:这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff">
    <RelativeLayout android:id="@+id/actionbarRelativeLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/actionbar_gradient">
        <ImageButton android:id="@+id/imageButton" android:layout_width="wrap_content" android:background="@drawable/stocktwits" android:layout_height="wrap_content"></ImageButton>
        <TextView android:layout_width="wrap_content" android:id="@+id/charCountTextView" android:text="140" android:layout_alignParentRight="true" android:layout_height="wrap_content" android:textColor="#ffffff" android:textStyle="bold" android:textSize="18sp" android:gravity="center_vertical" android:layout_centerVertical="true"></TextView>
    </RelativeLayout>
    <EditText android:layout_width="match_parent" android:id="@+id/composeEditText" android:focusable="true" android:hint="Share an idea with the community" android:gravity="left|top" android:layout_height="fill_parent" android:layout_weight="1"></EditText>
    <LinearLayout android:layout_width="match_parent" android:id="@+id/border" android:background="#c4c4c4" android:baselineAligned="false" android:layout_height="1dp"></LinearLayout>
    <LinearLayout android:layout_height="wrap_content" android:id="@+id/toolbarLinearLayout" android:orientation="horizontal" android:padding="5dip" android:layout_width="fill_parent" android:background="@drawable/gray_toolbar_gradient">
        <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/shortenButton" android:background="@drawable/shortenbutton" android:layout_weight="0"></Button>
        <LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_weight="1"></LinearLayout>
        <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/twitterCheckBox" android:textColor="#000000" android:layout_weight="0" android:background="@drawable/twittergraybutton"></CheckBox>
        <Button android:layout_height="wrap_content" android:layout_weight="0" android:id="@+id/sendButton" android:layout_width="wrap_content" android:background="@drawable/sharebutton"></Button>
    </LinearLayout>

</LinearLayout>

这是我的清单,我在其中指定了 softInputMode:

<activity android:name="ShareActivity"
              android:theme="@android:style/Theme.NoTitleBar"
              android:windowSoftInputMode="adjustResize">
    </activity>

推荐答案

确保你的 软输入模式设置为adjustResize,然后将带有工具栏的布局放在Activity的底部.

Make sure your soft input mode is set to adjustResize, then place the layout with your toolbar at the bottom of your activity.

例子:

<LinearLayout android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <FrameLayout android:id="@+id/my_content"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1">
        <!-- Your content here -->
    </FrameLayout>
    <LinearLayout android:id="@+id/my_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        <!-- Your toolbar items here -->
    </LinearLayout>
</LinearLayout>

这篇关于如何将布局放置在 android 屏幕键盘的正上方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Sending a keyboard event from java to any application (on-screen-keyboard)(将键盘事件从 java 发送到任何应用程序(屏幕键盘))
How to make JComboBox selected item not changed when scrolling through its popuplist using keyboard(使用键盘滚动其弹出列表时如何使 JComboBox 所选项目不更改)
Capturing keystrokes without focus(在没有焦点的情况下捕获击键)
How to check for key being held down on startup in Java(如何检查在Java中启动时按住的键)
Android - Get keyboard key press(Android - 获取键盘按键)
JFormattedTextField for Double still takes characters(Double 的 JFormattedTextField 仍然需要字符)