0

設計我在這裏有一個特殊的問題,我有一個相對佈局的活動,它有編輯文本作爲其子視圖。它也是線性佈局作爲子佈局,線性佈局包含按鈕和文本視圖。我知道這有點令人困惑,但我會提供快照以便清楚理解,甚至是我的活動XML。Android的UI與編輯文本

我面對這裏的問題是,當我在編輯文本挖掘了我的那一刻編輯文本輸入屏幕向上滑動我的編輯文本的底部有些文字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:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    tools:context=".ResultViewActivity" 
    android:background="@drawable/background" > 

<Button 
    android:id="@+id/homeButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:background="@drawable/homebtnselectr" /> 

<EditText 
    android:id="@+id/resultEditText" 
    android:layout_width="fill_parent" 
    android:layout_height="200dip" 
    android:layout_alignRight="@+id/homeButton" 
    android:layout_centerVertical="true" 
    android:background="@drawable/curve_corners" 
    android:ems="10" 
    android:gravity="top" 
    android:inputType="textMultiLine" 
    android:overScrollMode="always" 
    android:paddingBottom="6dp" 
    android:paddingLeft="12dp" 
    android:paddingRight="12dp" 
    android:paddingTop="6dp" 
    android:scrollbarStyle="insideInset" 
    android:scrollbars="vertical" 
    android:text="abcajfklafladfk" 
    /> 


    <LinearLayout 
     android:id="@+id/get_news_lin_layout" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:orientation="vertical" 
     android:layout_alignLeft="@+id/resultEditText" 
     android:layout_alignParentBottom="true" 
    > 

    <Button 
     android:id="@+id/getNews" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/getnews_btn_selectr" 
    /> 
    <TextView 
     android:id="@+id/get_news" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:text="Get News" 
     android:textSize="20dp" 
     android:textStyle="bold" /> 

    </LinearLayout> 
</RelativeLayout> 

this is normal activity without keyboard

this is same activity when tapped on edit text and keyboard appears

回答

2

在您的清單文件:把下面一行在您的活動

android:windowSoftInputMode="adjustPan" 
+0

我一定會嘗試一下,但如果你解釋它的實際作用,它將會是一個很好的幫助。 –

+0

這意味着,只要您的軟鍵盤出現在活動中,佈局將永遠不會影響adjustPane –

1

嘗試加入這一行到你的LinearLayout

android:layout_below="@+id/resultEditText" 
+0

我知道,這將解決這個問題,但不覺得做其右的方式,我不想馬上編輯短信我下面的按鈕。 –

0

我相信會發生這種情況,因爲儘管按鈕處於線性佈局,但線性佈局是相對佈局的子項。結束您的相對佈局後的EditText