我目前正在構建一個android應用程序,使用戶可以拍照並編寫它的詳細信息。該應用程序使用Sherlock庫。編輯文本和軟鍵盤在片段中的問題
我已經實現了一個SherlockFragment來顯示圖像和一些EditText和TextView以使用戶能夠輸入圖像的信息。但是,如果其中一個EditText處於焦點位置,則所有字段都將被推高,並彈出軟鍵盤。
這裏是我的佈局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="200dip"
android:layout_above="@+id/textView"
android:layout_marginTop="20dip"
android:layout_marginBottom="20dip"
android:contentDescription="desc" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title:"
android:textStyle="bold"
android:layout_above="@+id/editTextSimple"
android:layout_marginBottom="2dip"
android:textSize="15sp"/>
<EditText
android:id="@+id/editTextSimple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_marginBottom="4dip">
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description:"
android:textStyle="bold"
android:layout_above="@+id/editTextSimple1"
android:layout_marginBottom="2dip"
android:textSize="15sp"/>
<EditText
android:id="@+id/editTextSimple1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_marginBottom="12dip">
</EditText>
<Button android:textColor="#FF000000"
android:id="@+id/submitButton"
android:text="@string/memorySubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dip"
android:onClick = "submit"/>
</RelativeLayout>
據我瞭解,在活動中,一個必須把這個<activity android:windowSoftInputMode="...." >
在Android清單調整視圖時,軟鍵盤被要求。但是,我們如何設置這個碎片?
嗨Evos!謝謝您的回答!不幸的是,它仍然無法正常工作。我認爲這個問題可能是因爲'android:layout_above',儘管我不能太確定它。 – user1140240
你試過在這個參數中設置不同的變體嗎? – Evos
我做到了。我意識到問題在於佈局本身,而不是軟鍵盤。所以我實現了一個滾動視圖,它的工作原理!還是要謝謝你的幫助。 – user1140240