簡體   English   中英

出現鍵盤時布局向上移動

[英]Layout is moving up when keyboard appears

這是我的xml文件。......我正在嘗試構建布局,如果出現鍵盤,則可以滾動布局。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:fillViewport="true"
    android:focusableInTouchMode="true"
    >
<LinearLayout
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:orientation="vertical"
    android:weightSum="10">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight=".3"
        android:background="@drawable/squareshape"
        android:orientation="horizontal"
        android:weightSum="4">

        <TextView
            android:id="@+id/priority"
            android:layout_width="0dp"
            android:layout_height="32dp"
            android:layout_marginLeft="2dp"
            android:drawableLeft="@drawable/flag"
            android:gravity="center"
            android:text="@string/setpriority"
            android:textColor="@color/actionbarcolor"
            android:textSize="8dp"
            android:layout_weight="1.1"
            android:textStyle="bold" />

        <View
            android:layout_width=".1dp"
            android:layout_height="fill_parent"
            android:layout_marginLeft="2dp"
            android:layout_weight=".01"
            android:background="@android:color/black"></View>

        <TextView
            android:id="@+id/date"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="6dp"
            android:layout_marginRight="4dp"
            android:layout_weight="1"
            android:alpha=".5"
            android:drawableLeft="@drawable/date"
            android:gravity="center"
            android:tag="0"
            android:text="@string/setdate"
            android:textColor="@color/actionbarcolor"
            android:textSize="8dp"
            android:textStyle="bold" />
        />

        <View
            android:layout_width=".1dp"
            android:layout_height="fill_parent"
            android:layout_marginLeft="2dp"
            android:layout_weight=".01"
            android:background="@android:color/black"></View>

        <TextView
            android:id="@+id/ime"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="6dp"
            android:layout_marginRight="4dp"
            android:alpha=".5"
            android:layout_weight=".5"

            android:drawableLeft="@drawable/time"
            android:gravity="center"
            android:tag="0"
            android:text="@string/settime"
            android:textColor="@color/actionbarcolor"
            android:textSize="8dp"
            android:textStyle="bold" />
        />

        <View
            android:layout_width=".1dp"
            android:layout_height="fill_parent"
            android:layout_marginLeft="2dp"
            android:layout_weight=".01"
            android:background="@android:color/black"></View>

        <TextView
            android:id="@+id/location"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="2dp"
            android:alpha=".5"

            android:drawableLeft="@drawable/location"
            android:gravity="center"
            android:tag="0"
            android:text="@string/setlocation"
            android:textColor="@color/actionbarcolor"
            android:textSize="8dp"
            android:textStyle="bold"
            android:layout_weight="1.07" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:weightSum="2"
        android:layout_weight="6"
        android:orientation="horizontal"
        android:background="@drawable/squareshape">

        <EditText
            android:id="@+id/newnote_edittext_note"
            android:layout_width="0dp"
            android:layout_weight="1.5"
            android:layout_height="match_parent"
            android:background="@drawable/squareshape"

            android:gravity="top" />
        <ListView
            android:id="@+id/listview_list"
            android:layout_width="0dp"
            android:layout_weight=".5"

            android:layout_height="fill_parent"></ListView>
    </LinearLayout>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:layout_weight=".5"
        android:weightSum="3">

        <ImageView
            android:id="@+id/imageview_addphoto"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"

            android:src="@drawable/picturebuttonnor" />

        <ImageView
            android:id="@+id/imageview1_video"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"

            android:src="@drawable/videobuttonnor" />

        <ImageView
            android:id="@+id/imageview"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:contentDescription="newnote_imageview_audio"
            android:src="@drawable/audiobuttonnor" />
    </LinearLayout>

</LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="false"
        android:layout_alignParentBottom="true"
        >
    <include
        android:id="@+id/include"
        layout="@layout/bottomlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"></include>
    </LinearLayout>
    </RelativeLayout>

   </ScrollView>

當鍵盤出現時,布局正在向上移動。因此整個布局沒有滾動。如何停止此操作?請幫助...

嘗試在AndroidManifest.xml中定義以下屬性

android:windowSoftInputMode="stateVisible|adjustResize"

如果您的UI包含用戶可能需要在執行文本輸入后或執行操作時立即訪問的控件,則指定“ adjustResize ”非常重要。有關更多信息,請檢查

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM