草庐IT

android - 软键盘出现时向上移动布局

coder 2023-12-29 原文

我有带有电子邮件 ID、密码和登录按钮的登录页面。现在,当任何一个编辑文本获得焦点时,系统键盘就会隐藏我的登录按钮。当键盘出现时,我想将我的布局推到上方,使登录按钮保持在键盘上方。

P.S 我已经尝试了所有解决方案 adjust Pan|adjust Resize, adjust Pan,adjust Resize"

在 list 和 Java 代码中

但是没有一个对我有用。

 <ScrollView
    android:fillViewport="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/newl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">



<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="145dp"
    android:drawablePadding="8dp"
    android:layout_gravity="center_horizontal"
    android:src="@drawable/ic_clock"
    android:id="@+id/clock"
    />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Timetracker"
    android:fontFamily="LucidaGrande"
    android:textSize="30dp"
    android:textAlignment="center"
    android:layout_marginTop="15dp"
    android:layout_gravity="center_horizontal"
    android:id="@+id/tt"
    android:layout_below="@+id/clock"
    android:textColor="#FFFFFF"

    android:layout_centerHorizontal="true"
    />

<LinearLayout
    android:layout_below="@+id/tt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="30dp"

        >

        <ImageView
            android:layout_marginLeft="7dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_person_black_24dp"
           android:layout_centerVertical="true"
            />

        <Spinner
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="#FFFFFF"
            android:layout_marginLeft="9dp"
            android:drawablePadding="12dp"
            android:textSize="15dp"
            android:layout_marginRight="45dp"
            android:fontFamily="Sans Serif"
            android:layout_centerInParent="true"
            android:textColor="#FFFFFF"
            android:background="@android:color/transparent"
            android:id="@+id/spinner2"
            />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_arrow_drop_down_black_24dp"
            android:layout_alignParentRight="true"
            android:paddingRight="8dp"
            android:layout_centerVertical="true"/>

        </RelativeLayout>

    <View
        android:layout_below="@+id/rel"
        android:layout_width="match_parent"
        android:background="#FFF"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_height="1dp"/>


    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/lock"
        android:drawablePadding="12dp"
        android:layout_marginTop="30dp"
        android:layout_below="@+id/rel"
        android:layout_marginRight="7dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="7dp"
        android:hint="Password"
        android:background="@android:color/transparent"
        android:textColorHint="#FFFFFF"
        android:textSize="20dp"

        android:textColor="#FFFFFF"
        android:id="@+id/editText"
        android:inputType="textPassword"
        android:backgroundTint="#FFFFFF"
        />

    <View
        android:layout_below="@+id/editText"
        android:layout_width="match_parent"
        android:background="#FFF"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_height="1dp"/>


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:layout_below="@+id/editText"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:background="#FFFFFF"
        android:text="LOG IN"

        android:id="@+id/log"
        android:textColor="#D04045"/>



</LinearLayout>


    </RelativeLayout>

</ScrollView>

最佳答案

解决方案是在 ScrollView 上使用 android:fillViewport="true"。

你还可以使用 android:windowSoftInputMode="adjustResize"

这对我有用

关于android - 软键盘出现时向上移动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42689306/

有关android - 软键盘出现时向上移动布局的更多相关文章

  1. ruby-openid:执行发现时未设置@socket - 2

    我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass

  2. ruby - 多次弹出/移动 ruby​​ 数组 - 2

    我的代码目前看起来像这样numbers=[1,2,3,4,5]defpop_threepop=[]3.times{pop有没有办法在一行中完成pop_three方法中的内容?我基本上想做类似numbers.slice(0,3)的事情,但要删除切片中的数组项。嗯...嗯,我想我刚刚意识到我可以试试slice! 最佳答案 是numbers.pop(3)或者numbers.shift(3)如果你想要另一边。 关于ruby-多次弹出/移动ruby​​数组,我们在StackOverflow上找到一

  3. Ruby Readline 在向上箭头上使控制台崩溃 - 2

    当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby​​安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少

  4. ruby - 在 Ruby 中用键盘诅咒数组浏览 - 2

    我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作

  5. ruby-on-rails - 如何重命名或移动 Rails 的 README_FOR_APP - 2

    当我在我的Rails应用程序根目录中运行rakedoc:app时,API文档是使用/doc/README_FOR_APP作为主页生成的。我想向该文件添加.rdoc扩展名,以便它在GitHub上正确呈现。更好的是,我想将它移动到应用程序根目录(/README.rdoc)。有没有办法通过修改包含的rake/rdoctask任务在我的Rakefile中执行此操作?是否有某个地方可以查找可以修改的主页文件的名称?还是我必须编写一个新的Rake任务?额外的问题:Rails应用程序的两个单独文件/README和/doc/README_FOR_APP背后的逻辑是什么?为什么不只有一个?

  6. ruby - nanoc 和多种布局 - 2

    是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'

  7. ruby-on-rails - rbenv:从 RVM 移动到 rbenv 后,在 Jenkins 执行 shell 中找不到命令 - 2

    我从Ubuntu服务器上的RVM转移到rbenv。当我使用RVM时,使用bundle没有问题。转移到rbenv后,我在Jenkins的执行shell中收到“找不到命令”错误。我内爆并删除了RVM,并从~/.bashrc'中删除了所有与RVM相关的行。使用后我仍然收到此错误:rvmimploderm~/.rvm-rfrm~/.rvmrcgeminstallbundlerecho'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrcecho'eval"$(rbenvinit-)"'>>~/.bashrc.~/.bashrcrbenvversions

  8. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  9. ruby - 在 ruby​​ Selenium 中移动鼠标(move_to) - 2

    我正在尝试使用Ruby中的SeleniumWebDriver2.4模拟鼠标移动如果我运行测试,是否应该看到鼠标在我的屏幕上移动?我很困惑。我试过很多不同的方法示例代码:require'selenium-webdriver'driver=Selenium::WebDriver.for:firefoxdriver.navigate.to'http://www.google.com'element=driver.find_element(:id,'gbqfba')那我试过了driver.action.move_to(element).performdriver.mouse.move_to(e

  10. ruby - 在控制台中向左移动一个字符 - 2

    在控制台中,您可以像这样打印"\b"来删除光标左侧的字符(退格键)print"thelastcharisgoingtobeerased\b"#thelastcharisgoingtobeerased如何只向左移动一个位置而不是删除(向左箭头)? 最佳答案 这取决于终端类型和连接,但通常可以假定ANSI光标移动,因此光标向左是ESC+'['+'D':print"Thecursorshouldbebetweenthearrows:->参见http://ascii-table.com/ansi-escape-sequences.php获取

随机推荐