简体   繁体   English

出现键盘时显示滚动条

[英]Display Scrollbar when keyboard appears

Good Day, 美好的一天,

I'm having this problem, where is the scroll bar is not showing when the keyboard pops up. 我遇到了这个问题,键盘弹出时滚动条没有显示在哪里。 I would like to see the scroll bar every time or at least when the keyboard pops up not just when the device has smaller screens. 我希望每次或至少在弹出键盘时都看到滚动条,而不仅仅是在设备屏幕较小时。 Below is my xml. 下面是我的xml。

Note: I already added android:windowSoftInputMode="adjustResize" and still not showing up. 注意:我已经添加了android:windowSoftInputMode =“ adjustResize”并且仍然没有显示。 Thank you in advance. 先感谢您。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:background="@drawable/othersother">

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

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


<TextView
    android:text="ACTIVATE DEALER"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:textSize="20sp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="72dp"
    android:id="@+id/textView13" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:layout_marginTop="10dp"

    android:gravity="center"
    android:id="@+id/activeretname"
    android:hint="Full Name"
    android:layout_below="@+id/activeretnumber"
    android:layout_alignLeft="@+id/activeretnumber"
    android:layout_alignStart="@+id/activeretnumber"
    android:inputType="textPersonName" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:layout_marginTop="9dp"

    android:gravity="center"
    android:id="@+id/activeretusername"
    android:hint="Desired Username"
    android:inputType="textPersonName"
    android:layout_below="@+id/activeretname"
    android:layout_alignLeft="@+id/activeretname"
    android:layout_alignStart="@+id/activeretname" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:layout_marginTop="11dp"

    android:gravity="center"
    android:id="@+id/activeretsponsor"
    android:hint="Sponsor Username"
    android:inputType="textPersonName"
    android:layout_below="@+id/activeretusername"
    android:layout_alignLeft="@+id/activeretusername"
    android:layout_alignStart="@+id/activeretusername" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:layout_marginTop="9dp"

    android:gravity="center"
    android:id="@+id/activeretplacement"
    android:hint="Placement Username"
    android:inputType="textPersonName"
    android:layout_below="@+id/activeretsponsor"
    android:layout_alignLeft="@+id/activeretsponsor"
    android:layout_alignStart="@+id/activeretsponsor" />

<TextView
    android:text="Select Group"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/activeretplacement"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="9dp"
    android:id="@+id/textView16" />

<CheckBox
    android:text="A"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="13dp"
    android:id="@+id/activereta"
    android:layout_below="@+id/textView16"
    android:layout_alignLeft="@+id/textView13"
    android:layout_alignStart="@+id/textView13"
    android:layout_marginLeft="26dp"
    android:layout_marginStart="26dp"
    android:checked="true" />

<CheckBox
    android:text="B"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/activeretb"
    android:layout_marginRight="34dp"
    android:layout_marginEnd="34dp"
    android:layout_alignBaseline="@+id/activereta"
    android:layout_alignBottom="@+id/activereta"
    android:layout_alignRight="@+id/textView13"
    android:layout_alignEnd="@+id/textView13" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"

    android:gravity="center"
    android:id="@+id/activeretcity"
    android:hint="City or Municipality"
    android:inputType="textPersonName"
    android:layout_below="@+id/activereta"
    android:layout_alignLeft="@+id/activeretplacement"
    android:layout_alignStart="@+id/activeretplacement" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="number"
    android:ems="10"
    android:layout_marginTop="57dp"

    android:gravity="center"
    android:id="@+id/activeretnumber"
    android:hint="Mobile Number"
    android:layout_below="@+id/textView13"
    android:layout_centerHorizontal="true" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:ems="10"

    android:gravity="center"
    android:id="@+id/activeretcode"
    android:hint="Activation Code"
    android:layout_marginTop="14dp"
    android:layout_below="@+id/textView13"
    android:layout_alignLeft="@+id/activeretnumber"
    android:layout_alignStart="@+id/activeretnumber" />

<Button
    android:text="SEND"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="11dp"
    android:id="@+id/activeretsend"
    android:layout_below="@+id/activeretcity"
    android:layout_centerHorizontal="true" />
</RelativeLayout>
</ScrollView>
</LinearLayout>

There is no way to detect when the keyboard is shown (there are some hacks people have come up with, but they aren't accurate- they have false positives or negatives). 无法检测何时显示了键盘(人们想出了一些技巧,但它们不准确-它们具有错误的肯定或否定)。 So you can't have a scrollbar appear only when the keyboard is up. 因此,只有在键盘弹起时,才能显示滚动条。 Your best bet is to either keep the scrollbar on at all times (with android:fadeScrollbars="false" on the scrollview) if you really want this feature. 如果您确实想要此功能,最好的选择是始终保持滚动条处于打开状态(在scrollview上使用android:fadeScrollbars =“ false”)。 softInputMode resize may work better for you here, as I'm not sure if panning is sufficient to awaken scrollbars or not. 在这里,softInputMode调整大小可能会更好,因为我不确定平移是否足以唤醒滚动条。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM