当弹出键盘时,ScrollView渐变Textview在邻居视图上重叠

时间:2014-12-02 18:00:39

标签: android android-layout android-activity scrollview gradient

我只是在一个布局中创建消息阅读信息,我有下面的布局xml文件,其中包含带有Textviews的滚动视图(此textview具有我在java中动态创建的渐变颜色),在垂直scrollview的线性布局上是合适的键盘弹出。当我单击EditText视图时,键盘弹出窗口和所有textview相互重叠。我尝试了所有选项,如android:windowSoftInputMode和android:fitsSystemWindows =" true"一次又一次的结果。

我的布局xmlfile

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/parent"
android:fitsSystemWindows="true"
tools:context="com.talkeasy.messageperformancw.MainActivity" >

<HorizontalScrollView
    android:id="@+id/horizontalScrollView1"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/linearlayout_1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:background="#000000"
        android:orientation="horizontal" >

    </LinearLayout>
</HorizontalScrollView>

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="0dp" 
    android:layout_weight="1"
    android:background="#000000"
    android:fitsSystemWindows="true"
    android:fillViewport="true"
    android:isScrollContainer="true"
    android:splitMotionEvents="true"
     >

    <LinearLayout
        android:id="@+id/xmlid_l_message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:orientation="vertical" >
    </LinearLayout>
</ScrollView>
</LinearLayout>

在Keybord弹出之前:

enter image description here

弹出键盘后

enter image description here

如果你在键盘弹出时看到第二张图像,那么scrollview内部的视图会相互折叠,我不想使用任何layout_weight选项,我希望这个问题得到解决:(。Stackoverflow是我唯一的解决方案最后的希望..在此先感谢。

1 个答案:

答案 0 :(得分:1)

在键盘显示后尝试拨打linear.invalidate();linear.requestLayout();。我认为你的问题是视图没有重新计算它们在布局中的大小。

实际上我认为你可以在TextView中使用9.patch资源作为背景并为它们设置边距。我认为这会有所帮助。