【问题标题】:Keyboard keeps blocking my view... how to fix it?键盘一直挡住我的视线...如何解决?
【发布时间】:2019-03-09 11:37:07
【问题描述】:

我的键盘一直挡住我的视线。有没有办法解决这个问题?

当我点击描述 2 插入一些东西时,但是键盘太烦人了……我看不到我在输入什么……实际上这不是一页。其他页面也喜欢这个。我看不到我正在输入的内容,只有关闭键盘才能看到内容。

这是代码

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center|top">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ListView
                    android:id="@+id/listView1"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"></ListView>
            </LinearLayout>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="DATE:" />

                <TextView
                    android:id="@+id/Select_Date"
                    android:layout_width="60dp"
                    android:layout_height="38dp"
                    android:text="SELECT DATE"
                    android:textSize="19dp"
                    />

            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="TXN NO:" />

                <TextView
                    android:id="@+id/D_Txn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ems="10" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">


                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="NAME:" />

                <EditText
                    android:id="@+id/D_Name"
                    android:layout_width="273dp"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:inputType="textPersonName" />
            </TableRow>


            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="72dp"
                    android:layout_height="wrap_content"
                    android:text="AMOUNT:" />

                <EditText
                    android:id="@+id/D_Amount"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:inputType="number" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="110dp"
                    android:layout_height="wrap_content"
                    android:text="DESCRIPTION1:" />

                <Spinner
                    android:id="@+id/D_Description"
                    android:layout_width="match_parent"
                    android:layout_height="35dp"
                    android:background="@android:drawable/btn_dropdown"
                    android:spinnerMode="dropdown" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="60dp"
                    android:layout_height="wrap_content"
                    android:text="DESCRIPTION2:" />

                <EditText
                    android:id="@+id/Ds_Description"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:inputType="textPersonName" />


            </TableRow>
        </TableLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:gravity="center|bottom"
        android:orientation="horizontal">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TableRow>

                <Button
                    android:textColor="@color/my_color_state"
                    android:id="@+id/Db_New"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="NEW" />

                <Button
                    android:textColor="@color/my_color_state"
                    android:id="@+id/Db_Save"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:enabled="false"
                    android:text=   "SAVE" />
            </TableRow>

            <TableRow>

                <Button
                    android:textColor="@color/my_color_state"
                    android:id="@+id/Db_Print"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="PRINT" />

                <Button
                    android:textColor="@color/my_color_state"
                    android:id="@+id/Db_Back"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="BACK" />
            </TableRow>
        </TableLayout>
    </LinearLayout>

【问题讨论】:

标签: android user-interface interface


【解决方案1】:

在您的清单中,将此行添加到您的活动中:

android:windowSoftInputMode="adjustResize"

当可用布局大小发生变化时,它会调整您的活动。

编辑:

在您的案例中,您还必须在主容器上添加 ScrollView

【讨论】:

  • android:windowSoftInputMode="adjustResize" 不工作。如果我输入ScrollView,应用程序将崩溃...
  • 当我单击 EditText 并输入内容时。但是键盘会阻止 EditText。所以我看不到EditText....我不知道如何解释。但有时我会使用一些应用程序。单击编辑文本。并且键盘弹出并且EditText在键盘的上方,然后我不会阻止EditText。你明白了吗?
  • 是的,我知道你的问题是什么。但是 ScrollView 至少允许您在 Layout 太大时滚动。
  • 你可以在 Twitter 上联系我:@antitized
  • 检查一下。谢谢@Antonio
【解决方案2】:

转到您的清单并为所选活动添加此行

android:windowSoftInputMode="adjustPan"

例子:

    <activity
        android:name=".Activity.MainActivity"
        android:label="@string/title_activity_main"
        android:windowSoftInputMode="adjustPan">

【讨论】:

  • 那你还有其他一些错误的设置。我正在开发一个具有此功能且运行良好的应用程序
猜你喜欢
  • 1970-01-01
  • 2020-12-27
  • 1970-01-01
  • 2019-10-21
  • 1970-01-01
  • 1970-01-01
  • 2015-02-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多