屏幕底部带有按钮的scrollView [英] scrollView with Button at Bottom of screen

查看:67
本文介绍了屏幕底部带有按钮的scrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对表单数据使用滚动视图,并在屏幕底部使用一个按钮.我已经做到了.但是问题是,每当EditText聚焦并打开键盘时,按钮不会停留在屏幕底部,而是位于android键盘上方.我希望无论键盘是否打开,它都位于底部.

I have to use a scroll view for the form data and a button that should be at the bottom of the screen. I have achieved it. but the problem is whenever the EditText gets focused and the keyboard is opened the button does not stay at the bottom of the screen it comes just above the android keyboard. I want it to be there at the bottom even when the keyboard is opened or not.

我已经尝试使用滚动视图尝试 android:fillViewport ="true" ,但是它没有提供正确的输出.

I have tried the android:fillViewport="true" with scroll view but it does not give a proper output.

<?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout 
           xmlns:android="http://schemas.android.com/apk/res/android"

            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/lout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


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

                <LinearLayout
                    android:id="@+id/fout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="16dp"
                    android:paddingTop="10dp">

                    <ImageView
                        android:id="@+id/fimg"
                        android:layout_width="match_parent"
                        android:layout_height="250dp"
                        android:src="@drawable/addimg" />

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/vsubcusine"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingBottom="10dp"
                        android:paddingLeft="5dp"
                        android:paddingRight="5dp"
                        android:paddingTop="10dp"
            >

                        <EditText
                            android:id="@+id/add_food_title"
                            style="@style/textbox"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="Title for Food"
                            android:inputType="text"

                            />
                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/vcusine"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="cusine"
                        android:paddingBottom="10dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="0dp">

                        <Spinner
                            android:id="@+id/cusine"
                            style="@style/textbox"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="#fff"
                            android:padding="10dp" />
                    </android.support.design.widget.TextInputLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:paddingBottom="10dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="10dp">


                        <RadioGroup
                            android:id="@+id/isveg"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:paddingLeft="20dp">

                            <RadioButton
                                android:id="@+id/veg"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="2"
                                android:text="Veg" />

                            <RadioButton
                                android:id="@+id/nonveg"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="2"

                                android:text="Non-Veg" />

                        </RadioGroup>
                    </LinearLayout>

                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/vfprice"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingBottom="0dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="0dp"
                        >

                        <EditText
                            android:id="@+id/fprice"
                            style="@style/textbox"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:hint="price"
                            android:inputType="number" />


                    </android.support.design.widget.TextInputLayout>
                </LinearLayout>
            </ScrollView>


            <LinearLayout
                android:id="@+id/t"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="2">

                <Button
                    android:id="@+id/foodadd"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_weight="1"
                    android:background="@drawable/button"
                    android:text="ADD FOOD"
                    android:textColor="#FFF"
                    android:textStyle="bold" />
            </LinearLayout>

        </RelativeLayout>

推荐答案

清单中,只需将 android:windowSoftInputMode ="adjustPan" 添加到您的相应活动标签中:

In manifest, Just Add android:windowSoftInputMode="adjustPan" to your corresponding activity tag:

     <activity
        android:name=".YourActivity"
        android:windowSoftInputMode="adjustPan">

输出:

希望这会有所帮助.

这篇关于屏幕底部带有按钮的scrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆