【问题标题】:Soft keyboard lifts tabhost Upwards软键盘将tabhost向上提升
【发布时间】:2014-01-07 12:09:36
【问题描述】:

点击EditText打开软键盘时,我的 TabHost 会向上移动

屏幕截图

我做了什么

  • 对于我使用getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 隐藏软键盘的每个活动

我的尝试

  • 包括 android:windowSoftInputMode="adjustPan|adjustResize" 用于清单文件中的活动

我已经解决了许多已接受的问题,但是 android:windowSoftInputMode="adjustPan|adjustResize 不适用于我的情况。请建议如何应对这种情况。

编辑

tabhost.xml

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" />

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" />
</LinearLayout>

layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >

<RelativeLayout
    android:id="@+id/registrationLayout"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#333333" >

    <ImageView
        android:id="@+id/activity_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:contentDescription="@string/content_description"
        android:src="@drawable/logo" />


    <RelativeLayout
        android:id="@+id/rl2"
        android:layout_width="match_parent"
        android:layout_height="38dp"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/activity_logo"
        android:gravity="center_vertical" >

        <EditText
            android:id="@+id/searchEditText"
            android:layout_width="match_parent"
            android:layout_height="23dp"
            android:layout_marginLeft="6dp"
            android:layout_marginRight="6dp"
            android:background="@drawable/search_background"
            android:gravity="left|center_vertical"
            android:hint="Search for name"
            android:paddingLeft="6dp"
            android:textColor="@color/white"
            android:textSize="15sp" />

        <Button
            android:id="@+id/btn_search"
            android:layout_width="18dp"
            android:layout_height="18dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="9dp"
            android:layout_marginTop="4dp"
            android:background="@drawable/search_icon"
            android:gravity="right|center_vertical" />
    </RelativeLayout>
</RelativeLayout>

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/registrationLayout"
    android:divider="@android:color/black"
    android:dividerHeight="1dp" >
</ListView>

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleInverse"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:visibility="gone" />
</RelativeLayout>

提前致谢

【问题讨论】:

  • 将 android:layout_alignParentBottom="true" 放入您的 TabHost。
  • 编辑:添加了Layout.xml

标签: android android-layout android-tabhost android-view android-softkeyboard


【解决方案1】:

我得到了解决方案。

  • 我们必须使用android:windowSoftInputMode="adjustPan|adjustResize",但是如果布局包含任何ScrollView,那么ScrollView 必须具有android:isScrollContainer="false" 属性。
  • 更多详情请点击Here

【讨论】:

    【解决方案2】:
      <activity
            android:name="Your activity name"
            android:screenOrientation="portrait/Landscape"
            **android:windowSoftInputMode="adjustPan|adjustResize"** >
    

    【讨论】:

      猜你喜欢
      • 2020-12-18
      • 2021-11-28
      • 1970-01-01
      • 2016-12-21
      • 1970-01-01
      • 2013-02-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      相关资源
      最近更新 更多