android - AlignParentBottom + marginBottom 不能一起工作

标签 android android-layout android-relativelayout android-softkeyboard window-soft-input-mode

在我的 Activity View 中,我有 RelativeLayout,其中有两种布局:LinearLayout-"ll"(必须在屏幕顶部)和相对布局 - "rl “(必须在屏幕底部)。当我专注于 ll 中的 editText 时,它打开键盘并且我的 rl 上升并显示在 ll 上。然后我尝试使用 android:layout_below="@+id/ll" 但它没有用。我还尝试在 list 中添加带有各种参数的 android:windowSoftInputMode="" 但没有任何帮助。

SO 如何在键盘打开时保持 RelativeLayout“rl”在屏幕底部?

这是代码

<?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingTop="@dimen/main_container_padding"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:xxx="http://schemas.android.com/apk/res-auto" >

            <!-- Layout of username, password, Sign in button -->

            <LinearLayout 
                android:id="@+id/llusernamePassLogin"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:orientation="vertical"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:layout_marginTop="20dp"
                android:layout_gravity="center_horizontal" >

                <TextView 
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:text="@string/loginPageText" />

                <am.bs.xxx.view.EditTextBase
                    android:id="@+id/login_vcardnumber"
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/edit_text_height"
                    android:layout_margin="@dimen/edit_text_margin"
                    android:hint="@string/email"
                    android:inputType="text" />

                <am.bs.xxx.view.EditTextBase
                    android:id="@+id/login_password"
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/edit_text_height"
                    android:layout_margin="@dimen/edit_text_margin"
                    android:hint="@string/password"
                    android:inputType="textPassword" />


                <Button
                    android:id="@+id/signin"
                    style="@style/main_button"
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/edit_text_height"
                    android:layout_margin="@dimen/edit_text_margin"
                    android:background="@drawable/main_button_shape_selector"
                    android:onClick="createButtonClickListener"
                    android:text="@string/signIn" />

            </LinearLayout>

            <!-- Create VCard or Register layout -->
            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:layout_alignParentBottom="true"
                android:layout_marginBottom="40dp"
                android:layout_below="@+id/llusernamePassLogin" >

                <!-- Register button -->
                <LinearLayout 
                    android:id="@+id/llRegisterButtonLayout"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:orientation="vertical"
                    android:paddingBottom="1dp"
                    android:gravity="center_horizontal"
                    android:paddingRight="10dp" >

                    <ImageButton
                        android:id="@+id/login_register_button"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:src="@drawable/reg"
                        android:onClick="createButtonClickListener"
                        android:background="@color/transparent" />

                    <TextView 
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/registration" />    

                </LinearLayout>

                <!-- Create VCard button -->
                <LinearLayout 
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:orientation="vertical"
                    android:layout_toRightOf="@+id/llRegisterButtonLayout"
                    android:paddingBottom="1dp"
                    android:gravity="center_horizontal" >

                    <ImageButton 
                        android:id="@+id/create_vc_button"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:src="@drawable/create_vcard"
                        android:onClick="createButtonClickListener"
                        android:background="@color/transparent" />

                    <TextView 
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="@string/createVcard" />    

                </LinearLayout>


            </RelativeLayout>
    </RelativeLayout>

最佳答案

看起来您需要 android:windowSoftInputMode="adjustResize"并将您的根 RelativeLayout 标记为 isScrollContainer=true

关于android - AlignParentBottom + marginBottom 不能一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21016176/

相关文章:

java - 在Listview中实现自定义字体-Android

java - 不使用 onTouch 或 onItemClick 突出显示 ListView 的项目

android - relativeLayout边距问题,文本渗入其他 "fields"

Android布局-相对与框架

android - 设置framelayout边距及其子元素的宽度、高度和位置

java - 如何从 BIG HTML 字符串中删除一些标签?

java - 使用 volley 将图像上传到服务器,并在发布请求正文中包含多部分数据

Android:复选框选择器无法正常工作

android - 布局可能没用 - 不,它不是

java - 设置内容 View 层次结构