防止软键盘向上移动布局

时间:2013-05-21 09:04:03

标签: android xml

当软键盘显示时,它会从屏幕上推送其余内容。如何调整此内容。

我尝试过使用调整平移,调整调整大小和所有内容,但这些都没用。

这是我的布局

<RelativeLayout 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:orientation="vertical" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    tools:ignore="UselessParent" >

<RelativeLayout
    android:id="@+id/top_layout"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:background="@drawable/post_header_background"
    tools:ignore="UselessParent" >

    <TextView
        android:id="@+id/sender_name_txtvw"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="5dp"
        android:text="@string/compose_message"
        android:textColor="@android:color/black" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="3dp"
        android:layout_toRightOf="@+id/sender_name_txtvw"
        android:background="@null"
        android:hint="Enter Name"
        android:textSize="12sp"
        tools:ignore="HardcodedText" />
</RelativeLayout>

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/bottom_layout"
    android:layout_below="@+id/top_layout"
    tools:ignore="UselessLeaf" >

<RelativeLayout 
    android:id="@+id/bottom_layout"
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:background="@drawable/bg">


    <Button
        android:id="@+id/send_btn" 
        android:layout_alignParentRight="true"
        android:layout_width="50dp"
        android:layout_height="30dp"
        android:layout_centerVertical="true"
        android:background="#FF0000"
        android:layout_marginRight="10dp"/>

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:inputType="textMultiLine"
        android:layout_margin="5dp"
        android:layout_toLeftOf="@+id/send_btn"
        android:background="@drawable/radus_et_back"
        tools:ignore="TextFields"
        android:maxLines="10"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" />

</RelativeLayout>

在我的清单文件中,我添加了

 <activity  
           android:name="com.radus.ComposeMessageActivity" 
           android:screenOrientation="portrait"                    
           android:windowSoftInputMode="stateHidden|adjustResize|stateVisible"   /> 

任何帮助都将不胜感激。谢谢。

2 个答案:

答案 0 :(得分:0)

默认情况下,softKeyoard是否会出现问题..

然后尝试这个

活动 onCreate()

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

仅当您选择或关注EditText时才会出现键盘。

答案 1 :(得分:-1)

这可以解决您的问题:

<activity android:name=".your_activity" android:windowSoftInputMode="stateHidden" />
相关问题