首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当单击Keypad android时,布局不会滚动

当单击Keypad android时,布局不会滚动
EN

Stack Overflow用户
提问于 2017-09-15 04:58:30
回答 4查看 72关注 0票数 0

Login.xml

代码语言:javascript
复制
 <?xml version="1.0" encoding="utf-8"?>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background_1242_2208"
            android:fillViewport="true" >

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/linearLayout"

            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" 
            android:gravity="center_horizontal"
            android:orientation="vertical">

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.2"/>

            <TextView
                android:paddingTop="30dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp" 
                android:text="@string/patient_name"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <TextView
                android:id="@+id/patientname"
                android:layout_width="241dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:text=""
                android:textAlignment="center"
                android:textColor="@color/white_text" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/emergency_name"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/patientemegencynametext"
                android:layout_width="160dp"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:textColor="@color/white_text" />

            <TextView
                android:paddingTop="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/emergency_number"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/patientemegencynumbertext"
                android:layout_width="135dp"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:hint="021 1234567"
                android:inputType="phone"
                android:maxLength="12"
                android:textColor="@color/white_text" />
            <TextView
                android:paddingTop="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/address"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/address"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:paddingBottom="10dp"
                android:textColor="@color/white_text"
                android:inputType="textMultiLine"
                android:maxLines="2"/>

            <!--Next-->
            <Button
                android:id="@+id/loginbutton"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="30dp"
                android:background="@drawable/whitebuttonshape"
                android:textAllCaps="false"
                android:textStyle="bold"
                android:text="@string/next"
                android:textColor="@color/blue_text"
                tools:textAllCaps="false" />

            <!--Back-->
            <Button
                android:id="@+id/backbutton"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:textStyle="bold"
                android:layout_marginTop="15dp"
                android:background="@drawable/buttonshape"
                android:textAllCaps="false"
                android:text="@string/back"
                android:textColor="@color/white_text"
                tools:textAllCaps="false" />

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.4"/>

        </LinearLayout>
    </ScrollView>

AndroidManifest.xml用于登录活动。在这里,我添加了android:windowSoftInputMode="adjustResize",用于在打开Keypad.But时滚动,无论如何,我无法滚动该视图。

代码语言:javascript
复制
 <activity
     android:windowSoftInputMode="adjustResize"
     android:name=".activities.LoginActivity"
     android:screenOrientation="portrait"
     android:theme="@style/AppTheme" />

主题Style.xml

代码语言:javascript
复制
 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/black</item><!--Changes status bar colour-->
        <item name="colorAccent">@color/colorAccent</item>
    </style>

在这里,当我单击下面的编辑文本时,我无法滚动视图。当键盘打开时,我需要滚动完整的视图。我在这里尝试了很多解决方案,但我找不到合适的解决方案。

EN

回答 4

Stack Overflow用户

发布于 2017-09-15 05:15:21

使用TableLayout而不是使用线性布局和

代码语言:javascript
复制
scrollview height = match_parent
tablelayout height = wrap_content

将清单更改为adjustPan|adjustResize,its将工作

票数 0
EN

Stack Overflow用户

发布于 2017-09-15 05:24:52

代码语言:javascript
复制
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background_1242_2208"
            android:fillViewport="true"
            >


        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/linearLayout"
 android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" //change match_parent to wrap_content

            android:gravity="center_horizontal"
            android:orientation="vertical"

</LinearLayout>
</ScrollView>

//将行添加到活动标记中的菜单文件中

代码语言:javascript
复制
android:windowSoftInputMode="adjustNothing"
票数 0
EN

Stack Overflow用户

发布于 2017-09-15 05:25:54

这段代码在我的side.Try上运行得很好。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical"
            android:scrollbars="vertical">

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.2" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingTop="30dp"
                android:text="@string/patient_name"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <TextView
                android:id="@+id/patientname"
                android:layout_width="241dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:text=""
                android:textAlignment="center"
                android:textColor="@color/white_text" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/emergency_name"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/patientemegencynametext"
                android:layout_width="160dp"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:textColor="@color/white_text" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="20dp"
                android:text="@string/emergency_number"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/patientemegencynumbertext"
                android:layout_width="135dp"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/white"
                android:hint="021 1234567"
                android:inputType="phone"
                android:maxLength="12"
                android:textColor="@color/white_text" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="20dp"
                android:text="@string/address"
                android:textColor="@color/black_text"
                android:textSize="@dimen/text_size" />

            <EditText
                android:id="@+id/address"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:backgroundTint="@color/white"

                android:inputType="textMultiLine"
                android:maxLines="2"
                android:paddingBottom="10dp"
                android:textColor="@color/white_text" />

            <!--Next-->

            <!--android:background="@drawable/whitebuttonshape"-->
            <Button
                android:id="@+id/loginbutton"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="30dp"
                android:text="@string/next"
                android:textAllCaps="false"
                android:textColor="@color/blue_text"
                android:textStyle="bold"
                tools:textAllCaps="false" />

            <!--Back-->
            <!--android:background="@drawable/buttonshape"-->
            <Button
                android:id="@+id/backbutton"
                android:layout_width="match_parent"
                android:layout_height="35dp"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_marginTop="15dp"
                android:text="@string/back"
                android:textAllCaps="false"
                android:textColor="@color/white_text"
                android:textStyle="bold"
                tools:textAllCaps="false" />

            <android.support.v4.widget.Space
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.4" />
        </LinearLayout>
    </ScrollView>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46231946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档