首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部分UI屏幕向上显示

部分UI屏幕向上显示
EN

Stack Overflow用户
提问于 2015-12-02 07:52:50
回答 2查看 151关注 0票数 0

在屏幕上,我在顶部有一个编辑文本(大的包含4-5行的空间),下面的图像视图和底部的提交按钮。在键盘上,它不应该隐藏我的提交按钮。

当键盘出现时,我可以使用android:windowSoftInputMode="adjustResize"调整窗口的大小,这允许我不隐藏提交按钮,但它也调整了我的图像大小,这是我不想要的。

只有当键盘可见时,提交按钮才能向上移动,而不调整图像大小。

我也尝试了框架布局,但它没有,可能是我尝试错误的方式。任何帮助都将是学徒。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-12-02 09:58:48

应用这个,让我知道它是否还在发生。

activity_mian.xml

代码语言:javascript
复制
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical|center_horizontal"
    android:background="@drawable/xxx.jpg"
    android:orientation="vertical"
    tools:context=".LoginActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginTop="20dp"
            android:src="@drawable/logo_app" />

        <EditText
            android:id="@+id/edtEmail"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/login_textbox"
            android:ems="10"
            android:hint="Email"
            android:imeOptions="actionNext"
            android:inputType="textEmailAddress"
            android:singleLine="true"
            android:textColor="#ffffff"
            android:textCursorDrawable="@null" />

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

            <EditText
                android:id="@+id/edtPassword"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_gravity="center_vertical|center_horizontal"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/login_textbox"
                android:ems="10"
                android:hint="Password"
                android:imeOptions="actionDone"
                android:inputType="textPassword"
                android:singleLine="true"
                android:textColor="#ffffff"
                android:textCursorDrawable="@null" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_alignParentTop="true"
                android:layout_alignRight="@+id/edtPassword"
                android:layout_marginTop="2dp" />
        </RelativeLayout>

        <CheckBox
            android:id="@+id/checkBox_remember"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="20dp"
            android:button="@drawable/checkbox_selector"
            android:checked="true"
            android:focusable="false"
            android:focusableInTouchMode="true"
            android:text="  Remember Me"
            android:textColor="#ffffff" />    


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="10dp"
            android:orientation="vertical" >

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                        android:layout_gravity="top|center_vertical|center_horizontal"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:background="@drawable/btn_login" />


        </LinearLayout>


    </LinearLayout>

</ScrollView>

设置你的按钮,EditText等等。在一个线性布局中,后面跟着一个父ScrollView。

另一件事是在java文件中设置android:windowSoftInputMode="stateAlwaysHidden",其中您的xml文件是绑定的。

票数 1
EN

Stack Overflow用户

发布于 2015-12-02 10:33:23

随着@jigs回答中的一些变化,我得到了它的工作,并且发布可能会帮助像我这样的其他人

1)根布局在我的情况下是正常的相对布局。然后滚动视图内部滚动视图采用线性布局,其中指定编辑文本+图像视图。然后按下按钮。

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:background="@android:color/white"
    android:orientation="vertical">

<ScrollView
    android:id="@+id/scrollViewNotScrollable"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/user_name_container">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical"
        android:orientation="vertical"

        >

        <EditText
            android:id="@+id/input_feed"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:background="#00000000"
            android:ellipsize="start"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="start|center_vertical"
            android:hint="@string/feed_hint"
            android:imeActionLabel="Submit"
            android:imeOptions="actionSend"
       android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
            android:maxLines="5"
            android:minLines="3"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="25dp"
            android:textColor="@color/feed_sub_color"
            android:textColorHint="@color/light_gray"
            android:textCursorDrawable="@null" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp">
            <!--<ScrollView
                android:id="@+id/scroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:isScrollContainer="false"
                android:padding="4dp"

                android:layout_centerHorizontal="true"
                >-->
            <ImageView
                android:id="@+id/imgPreview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                android:layout_marginBottom="20dp"
                android:layout_marginTop="20dp"
                android:adjustViewBounds="true"
                android:background="@android:color/white"
                android:elevation="5dp"
                android:padding="4dp"
                android:visibility="gone" />
            <!--</ScrollView>-->
            <ImageView
                android:id="@+id/close_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/imgPreview"
                android:layout_marginLeft="-45dp"
                android:layout_marginTop="-20dp"
                android:layout_toRightOf="@+id/imgPreview"
                android:elevation="5dp"
                android:paddingBottom="15dp"
                android:src="@drawable/closeimage"
                android:visibility="gone" />

        </RelativeLayout>
    </LinearLayout>
</ScrollView>

<RelativeLayout
    android:id="@+id/user_name_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:fitsSystemWindows="true">

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@android:color/darker_gray" />

    <EditText
        android:id="@+id/feed_user_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:background="@null"
        android:ellipsize="end"
        android:fontFamily="san-serif-condensed"
        android:padding="12dp"
        android:singleLine="true"
        android:text="sherry's phone"
        android:textColor="@android:color/black"
        android:textSize="@dimen/feed_name_size"
        android:visibility="gone" />

    <TextView
        android:id="@+id/feed_user_name_textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:background="@null"
        android:ellipsize="end"
        android:fontFamily="san-serif-condensed"
        android:padding="12dp"
        android:paddingLeft="20dp"
        android:singleLine="true"
        android:text="sherry's phone"
        android:textColor="@android:color/black"
        android:textSize="@dimen/feed_name_size" />

    <ImageView
        android:id="@+id/edit_name"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:layout_gravity="end"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:scaleType="centerInside"
        android:src="@drawable/editname" />

    <Button
        android:id="@+id/done"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/rounded_corner_update_block"
        android:fontFamily="san-serif-medium"
        android:text="Done"
        android:textColor="@android:color/white"
        android:visibility="gone" />
</RelativeLayout>

</RelativeLayout>

2)android:windowSoftInputMode="adjustResize“在您的manifest.xml中

3)禁用java代码中的滚动(可选)

代码语言:javascript
复制
    mScrollView.setOnTouchListener( new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) 
            {
                  return true;
            }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34037424

复制
相关文章

相似问题

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