android– 软键盘将工具栏推入顶部状态栏

android– 软键盘将工具栏推入顶部状态栏,第1张

概述我已经完成了至少十个类似的SO问题,似乎没有任何效果.我有一个简单的相对布局,包括工具栏,文本视图,编辑文本等(请参阅下面的xml).当编辑文本被聚焦时,我需要软键盘向上推动我的布局,但在工具栏下(即工具栏固定),而键盘推动整个布局,包括工具栏?我已经尝试过adjustPan,adjustResi

我已经完成了至少十个类似的SO问题,似乎没有任何效果.

我有一个简单的相对布局,包括工具栏,文本视图,编辑文本等(请参阅下面的xml).

当编辑文本被聚焦时,我需要软键盘向上推动我的布局,但在工具栏下(即工具栏固定),而键盘推动整个布局,包括工具栏?

我已经尝试过adjustPan,adjustResize,scrollvIEws等没有成功,任何帮助都将不胜感激.

layout xml:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools"xmlns:app="http://schemas.androID.com/apk/res-auto"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"tools:context=".activitIEs.Test"><androID.support.design.Widget.AppbarLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:fitsSystemwindows="true"    androID:ID="@+ID/appbar_layout"    androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar">    <androID.support.v7.Widget.Toolbar        androID:ID="@+ID/toolbar"        androID:layout_wIDth="match_parent"        androID:layout_height="?attr/actionbarSize"        androID:background="?attr/colorPrimary"        app:popuptheme="@style/themeOverlay.AppCompat.light">    </androID.support.v7.Widget.Toolbar></androID.support.design.Widget.AppbarLayout><ScrollVIEw    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_below="@ID/appbar_layout">    <relativeLayout        androID:layout_wIDth="wrap_content"        androID:layout_height="match_parent">        <TextVIEw            androID:ID="@+ID/tv_Title"            androID:textSize="25dp"            androID:textcolor="@color/colorPrimaryDark"            androID:textStyle="bold"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_toleftOf="@+ID/iv"            androID:layout_alignParentleft="true" />        <TextVIEw            androID:ID="@+ID/tv_date"            androID:textSize="15dp"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_toleftOf="@+ID/iv"            androID:layout_alignParentleft="true"            androID:layout_below="@+ID/tv_Title"/>        <ImageVIEw            androID:ID="@+ID/iv"            androID:layout_marginRight="-6dp"            androID:layout_wIDth="150dp"            androID:layout_height="150dp"            androID:layout_alignParentRight="true"            androID:maxHeight="150dp"            />        <TextVIEw            androID:ID="@+ID/tv_description"            androID:layout_margintop="15dp"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_below="@+ID/iv"            androID:layout_centerHorizontal="true"            androID:textSize="15dp"            androID:textcolor="@color/colorPrimaryDark"/>        <ratingbar            androID:ID="@+ID/rb"                        androID:layout_centerHorizontal="true"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_below="@+ID/tv_description"            androID:numStars="5" />        <VIEw            androID:ID="@+ID/vIEw"            androID:layout_below="@+ID/rb"            androID:layout_wIDth="match_parent"            androID:layout_margintop="10dp"            androID:layout_height="1dp"            androID:visibility="visible"            androID:background="@color/colorPrimary"/>        <EditText            androID:ID="@+ID/et"            androID:layout_wIDth="match_parent"            androID:layout_height="100dp"            androID:padding="@dimen/activity_horizontal_margin"            androID:layout_below="@+ID/vIEw"            androID:gravity="top"            androID:background="@androID:color/transparent"            />        <button            androID:ID="@+ID/btn"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:textcolor="@color/textcolorPrimary"            androID:textSize="20dp"            androID:paddingtop="10dp"            androID:paddingBottom="10dp"            androID:layout_alignParentBottom="true"            />    </relativeLayout></ScrollVIEw></relativeLayout>

解决方法:

我在我的片段的onCreateVIEw上使用此代码,它工作正常.

getActivity()getwindow()setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_RESIZE).;

总结

以上是内存溢出为你收集整理的android – 软键盘将工具栏推入顶部状态栏全部内容,希望文章能够帮你解决android – 软键盘将工具栏推入顶部状态栏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1118229.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存