2017-01-27 7 views
2

Also versuche ich einen Text bearbeiten über eine textview, aber ich habe Schwierigkeiten damit. Wenn ich die Aktivität öffne, öffnet sich die Tastatur und wenn ich tippe, kann ich keine Texteingabe sehen. Auch wenn die Tastatur geöffnet wird, konzentriert es sich auf die Hälfte meiner imageview statt wo ich versuche, den Bearbeitungstext zu platzieren.Kann editText nicht sehen

hier ist mein xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_route_details" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.example.zach.BirdsboroClimbing.RouteDetails"> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <CheckBox 
      android:text="Route Climbed" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:id="@+id/routeCheckBox" 
      android:gravity="center" /> 

     <CheckBox 
      android:text="Add Note" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      android:id="@+id/noteCheckBox" 
      android:gravity="center" 
      /> 

     <EditText 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="text" 
      android:text="Name" 
      android:layout_centerVertical="true" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/noteEditText" 
      android:layout_below="@id/routeCheckBox" 
      android:background="#008000" 
      /> 

     <TextView 
      android:text="TextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/routeDetailsView" 
      android:textSize="18sp" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:layout_below="@id/noteEditText"/> 

     <ImageView 
      android:layout_below="@id/routeDetailsView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/routeImage" 
      android:scaleType="fitCenter" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:adjustViewBounds="true" /> 

    </RelativeLayout> 
</ScrollView> 

Vielen Dank für jede Hilfe!

+0

können Sie einen Screenshot hochladen, was geschieht? –

+0

Ich bin jetzt weg vom Computer, aber im Grunde ist es so, als ob der Bearbeitungstext nicht existiert. Ich kann es nicht sehen oder klicke darauf, um die Tastatur zu öffnen. – zsh5032

Antwort

1

Verwenden Sie in Ihrem Manifest softInputMode mit adjustPan. Dadurch wird das Betriebssystem den gesamten Bildschirm um den minimalen Betrag scrollen, der benötigt wird, um den Cursor über der Tastatur sichtbar zu machen.

<activity 
     android:name=".YourActivity" 
     android:windowSoftInputMode="adjustPan"> 
    </activity> 

bearbeiten: Ich für die question.You antwortete kann nicht sagen, es funktioniert nicht, wenn Sie Fehler auf Ihrem Layout haben !! Entferne unnötige Attribute.

Sie haben layout_alignParentBottom, layout_below, layout_alignParentStart alle von ihnen in diesem imageView (verwenden Sie die genaue, nicht alle von ihnen wollen)

ersetzen Ihre imageView wie diese

 <ImageView 
      android:src="@drawable/yourImage" 
      android:layout_below="@id/routeDetailsView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/routeImage" 
      android:scaleType="fitCenter" 
      android:adjustViewBounds="true" /> 
+0

Also habe ich das in meinem Manifest platziert, aber ich kann nicht sehen, wo mein Bearbeitungstext in meiner Aktivität ist. Wenn ich zum Beispiel auf den Bereich klicke, wo mein Text bearbeitet werden soll, passiert nichts. – zsh5032

+0

@ zsh5032 Es funktioniert gut, aber Ihr Layout war nicht in Ordnung, das ist der Grund überprüfen meine bearbeitete Antwort !! –

+0

OK danke. Ich bin jetzt von meinem Computer weg, aber ich werde es melden, sobald ich es ausprobieren kann. – zsh5032

1

Ok! Ich habe das Problem gefunden. Es tritt auf, wenn Sie ein Zeichen für die Bildansicht festlegen. Sie haben EditTextlayout_centerVertical="true" gemacht. Da das übergeordnete Element RelativeLayout ist, berechnet der EditText, wenn in imageview ein Zeichen vorhanden ist, seine Position neu und geht in die Mitte (vertikal) des übergeordneten Elements. Was ist eigentlich hinter dem ImageView? Also, Ihr EditText wird hinter die ImageView gestellt und da ImageView nach EditText in xml geschrieben wird, überlappt es den EditText.

Lösung wäre android:layout_centerVertical="true" von EditText zu entfernen.

+0

Hey ich habe deine Antwort auch versucht und es hat auch funktioniert. Ich wünschte ich könnte mehr als einen auswählen. Beantworte sie dir für die Hilfe! – zsh5032

1

Ersetzen Sie Ihre xml mit unter

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 


<RelativeLayout 
    android:id="@+id/activity_route_details" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    > 


      <CheckBox 
       android:text="Route Climbed" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:id="@+id/routeCheckBox" 
       android:gravity="center" /> 

      <CheckBox 
       android:text="Add Note" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentEnd="true" 
       android:id="@+id/noteCheckBox" 
       android:gravity="center" 
       /> 

      <EditText 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:inputType="text" 
       android:text="Name" 
       android:layout_centerVertical="true" 
       android:layout_centerHorizontal="true" 
       android:id="@+id/noteEditText" 
       android:layout_below="@id/routeCheckBox" 
       android:background="#008000" 
       /> 

      <TextView 
       android:text="TextView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/routeDetailsView" 
       android:textSize="18sp" 
       android:textAlignment="center" 
       android:textColor="@android:color/black" 
       android:layout_below="@id/noteEditText"/> 

      <ImageView 
       android:layout_below="@id/routeDetailsView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/routeImage" 
       android:scaleType="fitCenter" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:adjustViewBounds="true" /> 

     </RelativeLayout> 
    </LinearLayout> 
    </ScrollView> 

und hinzufügen unter der Linie in oncreate Aktivität Methode

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);