2013-04-07 19 views
1

我有一个只包含编辑文本视图的相对布局。但是,当edittext的内容增加时,我的标题栏会向上移动。我经历的大多数解决方案解决了键盘弹出时移动标题栏的问题。但是,如果内容增加,我没有发现任何东西。我还使用了android:isScrollContainer =“false”,如How to avoid soft keyboard pushing up my layout?这个帖子所建议的,但仍然是同样的问题。有没有办法阻止它?这里是我的xml文件 编辑文本内容时,Android标题栏被拉高

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroll_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:isScrollContainer="false" 
    android:background="@drawable/background" > 

    <EditText 
     android:id="@+id/hidden_edit_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:imeOptions="flagNoExtractUi" 
     android:inputType="textMultiLine" 
     android:singleLine="false" 
     android:paddingLeft="10sp" 
     android:paddingTop="5sp" 
     android:paddingRight="5sp" 
     android:scrollbars="vertical" 
     android:background="@android:color/transparent" 
     android:textSize="26sp" > 
    </EditText> 
</RelativeLayout> 

回答

1

我设法通过在scrollview中放置edittext并在清单中用adjustSize替换adjustPan来解决此问题。这是最后的工作布局

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rl_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background"> 
<EditText 
    android:id="@+id/hidden_edit_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@android:color/transparent" 
    android:imeOptions="flagNoExtractUi" 
    android:inputType="textMultiLine" 
    android:paddingLeft="10sp" 
    android:paddingRight="5sp" 
    android:paddingTop="5sp" 
    android:singleLine="false" 
    android:textSize="25sp" > 
</EditText> 
</ScrollView> 
0

尝试删除后运行代码:

android:background="@android:color/transparent" 
+0

还是一样的,我没有看到,也没有工作背景和布局转移 – Anurag 2013-04-08 17:47:13

0

让你的相对布局的高度和宽度,以wrap_content ..........可能起作用。因为当文字增加你的完整版面变化。尝试一下,并请rpy

+0

之间的任何关系,它仍然会认为 – Anurag 2013-05-07 18:56:02

0

通常这可以通过将android:windowSoftInputMode="adjustPan"属性添加到您在AndroidManifest文件中的活动来解决。

+0

外面我已经添加了这个属性我的清单 – Anurag 2013-05-07 18:56:23