【问题标题】:button at the bottom of layout not going up when keyboard comes键盘来时布局底部的按钮不会向上
【发布时间】:2019-01-25 01:42:43
【问题描述】:

我有一个RelativeLayout,其中顶部有一个EditText,底部有一个Button.. 当我单击EditText 时,我希望下一个Button 出现在上方键盘.. 我在Manifiest 中使用过调整面板,但它仍然不起作用

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

  <com.alimuzaffar.lib.pin.PinEntryEditText
            android:id="@+id/txt_pin_entry"
            android:focusable="true"
            android:layout_below="@+id/tv_phoneno_otp"
            android:layout_marginTop="@dimen/margin_top_otp_small"
            android:layout_width="@dimen/otp_dimen"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/margin_left_otp"
            android:cursorVisible="true"
            app:pinLineColors="@color/colorPrimary"
            android:digits="1234567890"
            android:inputType="number"
            android:maxLength="4"
            android:textIsSelectable="true"
            android:textSize="20sp"
            android:layout_marginStart="@dimen/margin_left_otp" />


   <Button
            android:id="@+id/btn_next_btn_otp"
            android:layout_width="@dimen/min_width"
            android:layout_height="@dimen/min_width"
            android:layout_alignParentRight="true"
            android:background="@drawable/back_btn"
            android:layout_marginRight="@dimen/margin_left_button_login"
            android:layout_marginEnd="@dimen/margin_left_button_login"
            android:layout_alignParentEnd="true"
            android:layout_below="@+id/txt_pin_entry"
            android:layout_marginTop="@dimen/margin_small_text_sub"/>


</RelativeLayout>

【问题讨论】:

  • 我假设这不是您的完整布局?看起来您的 PinEntryEditText 具有属性 android:layout_below="@+id/tv_phoneno_otp" 但该视图不存在。
  • 嘿,你在清单文件中添加了什么?

标签: android android-layout android-softkeyboard autoresize adjustpan


【解决方案1】:

在 Android Manifest 中,提供属性android:windowSoftInputMode="adjustResize"。这将在键盘显示时调整您的布局。

像这样:

<activity
        android:name=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize">
    </activity>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-27
    • 1970-01-01
    • 1970-01-01
    • 2017-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多