android - 当键盘可见时,EditText 下面的按钮不可见

标签 android button keyboard visible

我有一个表单和下面的一个按钮,当键盘可见时,它们应该是可见的,但我不知何故无法管理该状态。

  1. 在我的 Activity 中体现:

    android:label="@string/app_name"
    android:windowSoftInputMode="adjustResize" 
    android:screenOrientation="portrait"
    android:configChanges="orientation"
    
  2. xml 文件如下所示。

    <com.myapp.components.NonInvasiveScrollView      
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"    
        android:fillViewport="true"> 
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none"
            android:fadingEdgeLength="0dp"    
            android:paddingBottom="10dp"    
            android:orientation="vertical" >
    
            <HorizontalScrollView 
                android:id="@+id/hor_scrollview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                android:layout_weight="1"          
                android:fadingEdgeLength="0dp"
                android:scrollbars="none"
                android:overScrollMode="never"
                android:paddingTop="15dp"
                >
                <ImageView 
                    android:id="@+id/vizual"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/vizual"                                
                    />            
            </HorizontalScrollView>
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="5dp" >
    
                <RadioGroup
                    android:id="@+id/add_tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/add_fragment_margin"
                    android:layout_marginRight="@dimen/add_fragment_margin"
                    android:orientation="horizontal"
                    android:weightSum="2" >
    
                    <com.funtasty.appool.components.SegmentedControlButton
                        android:id="@+id/mam_napad"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:checked="true"                    
                        android:text="Mám nápad na aplikaci"
                        android:singleLine="true"                                                           
                        android:textSize="@dimen/smallText" />
    
                    <com.myapp.components.SegmentedControlButton
                        android:id="@+id/umim_tvorit"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:checked="false"
                        android:singleLine="true"
                        android:text="Umím tvořit aplikace"                    
                        android:textSize="@dimen/smallText" />
                </RadioGroup>
    
                <ViewFlipper
                    android:id="@+id/viewFlipper"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/add_tabs"
                    android:layout_marginLeft="@dimen/add_fragment_margin"
                    android:layout_marginRight="@dimen/add_fragment_margin"
                    android:layout_marginTop="5dp" >
    
                    <LinearLayout
                        android:id="@+id/add_mam_napad"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" >
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/rowMarginTop"
                             >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center_vertical|left"
                                android:focusable="true"
                                android:src="@drawable/ico_name" />
    
                            <EditText
                                android:id="@+id/name"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Jméno a příjmení"
                                android:singleLine="true"
                                android:inputType="text"
                                android:paddingBottom="5dp"
                                android:paddingLeft="10dp"     
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp" 
                                android:background="@drawable/edittext"
                                android:focusable="true"                            
                                android:textSize="@dimen/bigText"
                                android:textColor="@color/gray"                                                               
                                android:maxLines="1" />
                        </TableRow>
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/rowMarginTop"
                             >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center_vertical"
                                android:layout_marginRight="2dp"
                                android:src="@drawable/ico_mail" />
    
                            <EditText
                                android:id="@+id/email"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="0"
                                android:hint="E-mail"
                                android:inputType="textEmailAddress"
                                android:background="@drawable/edittext"
                                android:paddingBottom="5dp"
                                android:paddingLeft="10dp"     
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp" 
                                android:textColor="@color/gray"                        
                                android:textSize="@dimen/bigText"  
                                android:focusable="true"                        
                                android:maxLines="1" />
                        </TableRow>
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" 
                            android:layout_marginTop="@dimen/rowMarginTop"
                            >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center_vertical"
                                android:layout_marginRight="2dp"
                                android:src="@drawable/ico_bulb" />
    
                            <EditText
                                android:id="@+id/message"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="0"
                                android:background="@drawable/edittext"
                                android:paddingLeft="10dp"     
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp" 
                                android:gravity="center_vertical"
                                android:textSize="@dimen/bigText"
                                android:textColor="@color/gray"                            
                                android:inputType="textMultiLine|textImeMultiLine" 
                                android:maxLines="10"
                                android:focusable="true"
                                android:imeOptions="actionDone"
                                android:hint="Popiš svůj nápad" />
                        </TableRow>
                    </LinearLayout>
    
                    <LinearLayout
                        android:id="@+id/add_umim_tvorit"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" >
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/rowMarginTop"
                             >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"                            
                                android:layout_gravity="center_vertical|left"
                                android:src="@drawable/ico_name" />
    
                            <EditText
                                android:id="@+id/name_umim_tvorit"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="0"
                                android:hint="Jméno a příjmení"
                                android:singleLine="true"
                                android:textIsSelectable="true"
                                android:inputType="text"
                                android:paddingBottom="5dp"
                                android:background="@drawable/edittext"
                                android:paddingLeft="10dp"     
                                android:focusable="true"
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp"
                                android:textColor="@color/gray"
                                android:textSize="@dimen/bigText"                                           
                                android:maxLines="1" />
                        </TableRow>
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/rowMarginTop"
                             >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="2dp"
                                android:layout_gravity="center_vertical"
                                android:src="@drawable/ico_mail" />
    
                            <EditText
                                android:id="@+id/email_umim_tvorit"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="0"
                                android:hint="E-mail"
                                android:inputType="textEmailAddress"
                                android:paddingBottom="5dp"
                                android:background="@drawable/edittext"
                                android:paddingLeft="10dp"     
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp"
                                android:textColor="@color/gray"
                                android:textSize="@dimen/bigText" 
                                android:focusable="true"                            
                                android:maxLines="1" />
                        </TableRow>
    
                        <TableRow
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/rowMarginTop"
                             >
    
                            <ImageView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="2dp"
                                android:layout_gravity="center_vertical"
                                android:src="@drawable/ico_bulb" />
    
                            <EditText
                                android:id="@+id/message_umim_tvorit"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_weight="0"
                                android:background="@drawable/edittext"
                                android:paddingLeft="10dp"     
                                android:layout_marginLeft="2dp"
                                android:layout_marginRight="2dp" 
                                android:textSize="@dimen/bigText" 
                                android:textColor="@color/gray"
                                android:focusable="true"
                                android:inputType="textMultiLine"               
                                android:hint="Napiš něco o sobě" />
                        </TableRow>
                    </LinearLayout>
                </ViewFlipper>
    
                <Button
                    android:id="@+id/button_odeslat"
                    android:layout_width="match_parent"
                    android:layout_height="48dp"
    
                    android:layout_below="@id/viewFlipper"
                    android:layout_centerHorizontal="true"      
                    android:gravity="center"          
                    android:layout_marginLeft="@dimen/add_fragment_margin"
                    android:layout_marginRight="@dimen/add_fragment_margin"                
                    android:background="@drawable/bg"
                    android:text="Odeslat"
                    android:textColor="@drawable/button_color"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:enabled="false"
    
                    android:layout_marginTop="10dp"
                    android:textStyle="bold" />
            </RelativeLayout>
        </LinearLayout>
    
    </com.myapp.components.NonInvasiveScrollView>
    

我不明白为什么 softInputMode 不起作用:/我只想让按钮在键盘上方的编辑文本中可见。

最佳答案

在 list 中,对于此 Activity ,将 windowSoftInputMode 更改为:

android:windowSoftInputMode="adjustPan"

这将导致布局在显示键盘时向上移动,使按钮可见。

关于android - 当键盘可见时,EditText 下面的按钮不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16918139/

相关文章:

android - Gradle 5.x - 将我的库发布到 Maven Local 时出错

Java:如何禁用java中的按钮?

html - 为什么 facebook 使用提交按钮而不仅仅是点赞按钮的链接?

keyboard - Enter 键在 Netbeans 7.1 上不起作用

java - 如何在没有 JavaFX 监听器的情况下检查键是否关闭?

ios - UITextField 属性 KeyboardType 未按预期显示

android - Intent 过滤器上的 ActivityMonitor ACTION_SENDTO 未命中

java - Y 偏移,坦克上的轨迹 - 三角学

java - 在 SQLITE 中处理表 (android)

java - Android在父类xml中声明textview并在子类中设置监听器