我在ScrollViews中的EditText滾動行爲有問題,通常它會滾動滾動內容,如果鍵盤打開它。但是,如果你動態地在scrollview裏面填充佈局,鍵盤會推高整個屏幕,其他任何人都有過這個問題。 在此先感謝。ScrollView不響應鍵盤
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header_area" >
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
此示例工作正常,線性佈局在滾動視圖中滾動,但它顯示滾動甚至鍵盤關閉。我無法使用固定高度。
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:layout_below="@+id/header_area" >
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
我已經嘗試過下面的xml,它在新項目上按預期工作,但在我的項目中推高窗口。我發現一些其他人有這個問題,我會盡快分享解決方案。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/header_area"
android:layout_width="match_parent"
android:layout_height="50dip" >
</RelativeLayout>
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
你在做LinearLayout裏面添加新的視圖哪個父視圖是ScrollView? – Herry
是的,在scrolView中使用linearLayout。將視圖推入@ + id/contentHolder – ymutlu
您在LinearLayout右側有更多的EditText。您可以顯示您的問題的屏幕截圖。 – Herry