我在新的Android KitKat(4.4)中使用半透明操作栏/导航栏时出现问题windowSoftInputMode="adjustResize".
Normaly将InputMode更改为adjustResize,应用程序应该在键盘显示时自行调整大小......但是在这里它不会!如果我删除透明效果的行,则调整大小正常.
因此,如果键盘可见,我的ListView就在它下面,我无法访问最后几个项目.(只能手动隐藏键盘)
AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XYZ"
android:versionCode="23"
android:versionName="0.1" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.XYZStyle" >
<activity
android:name="XYZ"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
值-V19/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.XYZStyle" parent="@style/Theme.AppCompat.Light">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
fragment.xml之
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView_contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="true"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true"
android:paddingBottom="@dimen/navigationbar__height" >
</ListView> …Run Code Online (Sandbox Code Playgroud) android resize statusbar window-soft-input-mode android-4.4-kitkat
我有一个在ImageView上面有一个Edittext字段的视图.当键盘出现时,我希望窗口调整大小,以便键盘不再隐藏EditText.在我宣布的AndroidManifest文件中android:windowSoftInputMode="adjustResize",屏幕调整大小,但问题是我希望ImageView不能重新调整大小.如何使ImageView不受影响?
我可以仅使用ImageView来扩充其他布局,还是调整大小仍会影响它?

编辑:我需要使用键盘,但它隐藏了我的EditText,我需要它滚动,所以键盘没有隐藏它.
我正在使用三星平板电脑.
我的风格:
parent="android:Theme.Holo.NoActionBar.Fullscreen"
Run Code Online (Sandbox Code Playgroud)
这些EditText字段位于可滚动视图中,如下所示:
片段布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/depot_code"/>
<EditText
android:hint="@string/enter_depot_code"
android:id="@+id/etlocationId"
android:imeOptions="actionNext"
android:inputType="number"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="12"
android:singleLine="true">
<requestFocus/>
</EditText>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/name"/>
<EditText
android:hint="@string/enter_name"
android:id="@+id/etname"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="24"
android:singleLine="true"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:text="@string/street"/>
<EditText
android:hint="@string/enter_street"
android:id="@+id/etstreet"
android:imeOptions="actionNext"
android:inputType="textPostalAddress"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:lines="1"
android:maxLength="24"
android:singleLine="true"/>
<TextView
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) android android-fragments samsung-mobile window-soft-input-mode imeoptions
我正在使用 jetpack compose (1.0.0-beta09) 在我的项目上实现一个屏幕,但我在屏幕上遇到了一个问题,即使键盘打开,页脚也需要始终可见,我知道我们有android 上的“adjustResize”在正常活动中解决了这个问题(我有很多带有这种页脚类型的屏幕并且它正在工作),但是在撰写时,如果我将 adjustmentResize 放在清单上或活动的 onCreate 方法上,键盘将继续隐藏页脚:
这是我没有打开键盘的屏幕,只是为了弄清楚我在说什么
这就是键盘打开的屏幕
清单活动标签,我试图打开屏幕,键盘已经打开,页脚在他上方可见:
<activity
android:name=".presentation.creation.billing.NewBookingBillingActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AppThemeBase.Compose"
android:windowSoftInputMode="stateVisible|adjustResize"/>Run Code Online (Sandbox Code Playgroud)
onCreate方法:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
injectFeature()
initView()
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
setContent {
BuildScreen()
}
}Run Code Online (Sandbox Code Playgroud)
我知道在清单和 onCreate 上使用 setSoftInputMode 是多余的,但我正在尝试任何方法。
-
我的屏幕合成范围:
Column(fillMaxSize){
- AppBar
- Box(fillMaxSize){
//lazycolumn used to enable scroll with bottom padding to prevent last item to be hided below the footer
- LazyColumn(fillMaxSize | contentPadding) {
//TextFields of the screen
}
//footer
- Box(fillMaxWidth | …Run Code Online (Sandbox Code Playgroud)android android-manifest window-soft-input-mode adjustpan android-jetpack-compose
我知道android:windowSoftInputMode清单属性可以使用以下方法以编程方式设置:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Run Code Online (Sandbox Code Playgroud)
有没有办法以编程方式获得此值?我没有看到相应的getter方法.
我在我的Android应用程序中有以下布局但我windowSoftInputMode="adjustResize"在活动中遇到问题:名为"容器"的LinearLayout包含多个EditTexts但当其中一个有焦点并且键盘出现时,Activity不会调整大小并且EditText隐藏在键盘后面.我认为这与它有关,CoordinatorLayout但我无法弄清楚它有什么问题.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#F0f0f0">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll"
app:contentScrim="?attr/colorPrimary">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="?attr/actionBarSize"
android:padding="15dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<EditText
android:id="@+id/titleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="60"
android:hint="Title"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<EditText
android:id="@+id/descriptionEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="120"
android:hint="Description"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android android-layout window-soft-input-mode android-coordinatorlayout
我有一个在 WebView 中显示 HTML 表单的活动。这是我的清单:
<application
android:allowBackup="true"
android:label="@string/app_name" >
<activity
android:name=".SMFeedbackActivity"
android:label="@string/app_name"
android:screenOrientation="locked"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
和活动的布局:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sm_feedback_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)
当点击 WebView 中的文本输入元素时,会发生预期的 adjustResize 行为:活动调整大小以显示软件键盘,同时保持文本输入的焦点和可见性。但是,如果我滚动然后点击页面上的任何其他输入元素(例如单选按钮),WebView 将滚动回我之前编辑的文本输入。
当我在同一台设备上的 Chrome 中编辑同一个表单时,不会发生这种行为。我点击文本字段进行编辑,然后可以滚动页面上的其他地方并选择其他输入,而页面不会滚动回文本输入。
问题似乎与 Android WebView 本身和软件键盘有关。有谁知道如何解决这个问题?
我们可以设置android:windowSoftInputMode="stateVisible|adjustResize|adjustPan"在用户单击"编辑文本字段"时调整屏幕视图.
我想以HTML形式做同样的事情.当用户单击文本框时,应该自动调整视图,以便用户可以轻松地键入,以及他们可以看到他们正在键入的内容.
看到不同

我如何在Android中使用Phone Gap做同样的事情.我希望你能以正确的方式指导我.
感谢您阅读我的查询.
我有一个活动,其布局内容如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
style="@style/ToolBarStyle.Event" />
<com.mypackage.corecode.ui.view.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary_color" />
<android.support.v4.view.ViewPager
android:id="@+id/vendor_main_tabview_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在viewpager中,我有一个片段,它具有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<EditText
android:theme="@style/ScrollableContentThemeNoActionBar"
android:id="@+id/edit_text_vendor_sms_phone_number"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:inputType="number" />
<Button
android:id="@+id/button_send_sms"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
当片段内的内容不适合屏幕时,滚动视图允许用户查看屏幕下方的内容.(按预期工作)
问题是当edittext获得焦点时,键盘与edittext区域重叠,而不是滚动视图导致内容滚动.
我希望片段能够处理键盘和scrollview以适应屏幕上的键盘.
或者我错了,是否对键盘负责?由于活动布局中的根视图是linearlayout,它是否限制了扩展?
我尝试用滚动视图包装活动布局的整个内容,但是如果我没有给它一个固定的大小,这次viewpager不会出现在屏幕上.即使我这样做,我最终在片段内部有一个滚动视图,它位于主布局的滚动视图下方,而键盘仍然在编辑文本上方盘旋.
我在这里有点迷失,我的目标是能够在编辑文本聚焦时滚动片段内容,而是键盘当前与edittext重叠.
我adjustPan在我的应用程序中使用了一些问题,因为它不能正常工作.其他一些用户也遇到过这个问题,所以我认为分享这个问题很重要(单击EditText时布局不会向上移动).
注意:我使用的是Android Studio,而我正在使用"即时应用",因此文件的位置会有所不同.
当我adjustPan在布局中使用时,我的活动不会向上移动到EditText软键盘上方显示的位置(请参阅图像详细信息).无论您是在Manifest文件还是Java文件中使用它,都会出现相同的结果.
不仅如此,最奇怪的部分是状态栏变得透明,而应该在通知图标后面的深蓝色条有点下降(参见图像详细信息).
我尝试过多次尝试解决这个问题,比如使用adjustResize,setOnTouchListener但我收到的这两个答案都没有解决这个问题.
我仍然无法弄清楚这个问题的原因,所以关于如何发现这个问题的原因的任何答案或评论也没关系.
这是我的一些代码:
清单文件:
<activity
android:name=".Input_Activity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
Run Code Online (Sandbox Code Playgroud)
Java文件:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
public class Input_Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_input__activity);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
}
Run Code Online (Sandbox Code Playgroud)
XML文件:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Input_Activity">
<EditText
android:layout_width="214dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:inputType="number|numberDecimal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.585"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.725" /> …Run Code Online (Sandbox Code Playgroud) android android-edittext window-soft-input-mode adjustpan android-statusbar
android ×10
adjustpan ×2
cordova ×1
imeoptions ×1
keyboard ×1
resize ×1
scrollview ×1
statusbar ×1
webview ×1