2014-06-22 30 views
0

我有一個editText場在我的佈局爲:的EditText不自動滾動的第二個條目

<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" 
tools:context="com.dyces.teacher.app.MainActivity"> --> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:src="@drawable/snowcitblacker" 
    android:scaleType="centerCrop" /> 


<ImageView 
    android:layout_width="250dp" 
    android:layout_height="250dp" 
    android:src="@drawable/nocovertranss" 
    android:scaleType="fitCenter" 
    android:minWidth="450px" 
    android:minHeight="450px" 
    android:id="@+id/teachName" 
    android:layout_alignParentTop="true" 
    android:layout_marginTop="20dp" 
    android:layout_alignLeft="@+id/guess" 
    android:layout_alignStart="@+id/guess" /> 

<ImageView 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:src="@drawable/play" 
    android:layout_below="@+id/teachName" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginTop="270dp" 
    android:id="@+id/play"/> 

<ImageView 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:src="@drawable/pause" 
    android:layout_toLeftOf="@+id/play" 
    android:layout_alignBottom="@+id/play" 
    android:id="@+id/pause"/> 

<ImageView 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:src="@drawable/stop" 
    android:layout_toRightOf="@+id/play" 
    android:layout_alignBottom="@+id/play" 
    android:id="@+id/stop"/> 

<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:minWidth="250dp" 
    android:minHeight="50dp" 
    android:hint="Enter Guess Here" 
    android:textColorHint="#ffffff" 
    android:textColor="#ffffff" 
    android:gravity="center" 
    android:id="@+id/guess" 
    android:paddingBottom="10dp" 
    android:layout_below="@+id/play" 
    android:layout_alignLeft="@+id/button2" 
    android:layout_alignStart="@+id/button2" 
    android:layout_marginTop="34dp" 
    android:inputType="textNoSuggestions"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Check" 
    android:textColor="#F0EEEE" 
    android:background="@drawable/buttonback" 
    android:minWidth="250dp" 
    android:id="@+id/button2" 
    android:layout_marginTop="33dp" 
    android:layout_below="@+id/guess" 
    android:layout_centerHorizontal="true" /> 

在運行我的手機上的應用程序,當我在editText現場挖掘,佈局調整自己,使editText字段正好在鍵盤上方並且可見。 問題是當我嘗試再次敲擊該字段時(最小化鍵盤後),佈局不會調整此時間。

在下面的兩張圖片中,在第一張屏幕截圖上,「Enter Guess Here」是editText字段的提示,但在第二張屏幕截圖中,此字段現在被鍵盤隱藏。第二張屏幕截圖是在鍵盤被最小化之後拍攝的。

"Enter Guess Here" is the hint for the <code>editText</code> field

As evident the field is now hidden by the keyboard

+0

你使用scrollview作爲根容器嗎? –

+0

你可以顯示你的完整佈局或主視圖組。 – Ranjit

+0

@RanjitPati剛剛編輯整個佈局的問題。 –

回答

0

這是因爲您沒有使用ScrollView作爲根容器發生。如果您將RelativeLayout置於ScrollView之內,那麼它應該可能工作。

+0

不幸的是,它仍然不會自動調整。 –

+0

沒有這不是問題,因爲它甚至可以在沒有滾動條的情況下進行調整。 –

0
Try to use Scroll View, Put all your code inside scroll view and check for the output, thanks 
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      tools:context="com.dyces.teacher.app.MainActivity" > 

      <ImageView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:scaleType="centerCrop" 
       android:src="@drawable/snowcitblacker" /> 

      <ImageView 
       android:id="@+id/teachName" 
       android:layout_width="250dp" 
       android:layout_height="250dp" 
       android:layout_alignLeft="@+id/guess" 
       android:layout_alignParentTop="true" 
       android:layout_alignStart="@+id/guess" 
       android:layout_marginTop="20dp" 
       android:minHeight="450px" 
       android:minWidth="450px" 
       android:scaleType="fitCenter" 
       android:src="@drawable/nocovertranss" /> 

      <ImageView 
       android:id="@+id/play" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:layout_alignParentTop="true" 
       android:layout_below="@+id/teachName" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="270dp" 
       android:src="@drawable/play" /> 

      <ImageView 
       android:id="@+id/pause" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:layout_alignBottom="@+id/play" 
       android:layout_toLeftOf="@+id/play" 
       android:src="@drawable/pause" /> 

      <ImageView 
       android:id="@+id/stop" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:layout_alignBottom="@+id/play" 
       android:layout_toRightOf="@+id/play" 
       android:src="@drawable/stop" /> 

      <EditText 
       android:id="@+id/guess" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/button2" 
       android:layout_alignStart="@+id/button2" 
       android:layout_below="@+id/play" 
       android:layout_marginTop="34dp" 
       android:gravity="center" 
       android:hint="Enter Guess Here" 
       android:inputType="textNoSuggestions" 
       android:minHeight="50dp" 
       android:minWidth="250dp" 
       android:paddingBottom="10dp" 
       android:textColor="#ffffff" 
       android:textColorHint="#ffffff" /> 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/guess" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="33dp" 
       android:background="@drawable/buttonback" 
       android:minWidth="250dp" 
       android:text="Check" 
       android:textColor="#F0EEEE" /> 
     </RelativeLayout> 
    </ScrollView> 

</RelativeLayout> 
+0

試過了,問題仍然存在 –

+0

嘗試在清單文件中的活動定義中添加以下內容: android:windowSoftInputMode =「adjustResize」 – Reena

+0

也是這樣試過的。隨着adjustPan。 –