2016-05-31 11 views
0

Ich muss herausfinden, warum ich immer die Android-Tastatur angezeigt bekomme, da ich meine EditText mit dem aktivierten Attribut auf false gesetzt habe. Das Wurzelelement meiner Layout-Datei ist ein ScrollView. Wenn ich das ScrollView-Element herausnehme, funktioniert es perfekt mit einem Root-Element wie LinearLayout.Disabled EditText Element Display Tastatur

Ist dies das erwartete Verhalten für eine ScrollView, oder ist es nur eine fehlerhafte Sache? (Ich bekomme nicht den Punkt, eine ScrollView mit einem Text editierbaren Element Verhalten zu haben, wenn das der Fall ist).

nur als Statist, einige meiner Layout-Code ...

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

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="8dp" 
    android:paddingBottom="8dp"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Lorem ipsum dolor sit amet" 
     android:layout_marginBottom="20dp" 
     /> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_marginBottom="20dp"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <ImageView 
       android:id="@+id/input_name_icon" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@mipmap/ic_idcard_icon" 
       /> 
      <EditText 
       android:id="@+id/personal_setting_name" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/input_name_icon" 
       android:enabled="false" 
       android:text="First Name" /> 

nicht stressen, werde ich meinen String und Dimensionen richtig ... ändern; D

+0

Sieht aus wie buggy Verhalten (aber es gibt immer die Möglichkeit, dass es in anderen Teil Ihres Codes gebrochen ist). Haben Sie versucht, mit Android umgehen: focusable = "false"? – sandrstar

+0

Nein, aber muss ich fokussierbar zurück auf "true" setzen, wenn ich es aktiviert habe? –

+0

Sicher, Sie müssen es auf True setzen, dann benötigt. Genauso wie aktiviert. – sandrstar

Antwort

0

Wenn Sie Möchten Sie vermeiden, dass die Android-Tastatur bei jedem Öffnen Ihrer Aktivität mit ScrollView angezeigt wird, müssen Sie android:focusableInTouchMode="true" platzieren, aber nicht im EditText. Sie müssen es in der ScrollView wie folgt setzen:

<ScrollView 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="copsonic.com.SoundExchange.demoApp.FragmentTransmitter"> 


    <!-- Common template for all fragments --> 
    <RelativeLayout 
     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" 
     android:focusableInTouchMode="true"> 


     <EditText 
      android:id="@+id/editTextmessage2Send" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_below="@+id/button_send_msg" 
      android:ems="10" 
      android:hint="@string/edit_message" > 

     </EditText> 
    </RelativeLayout> 



</ScrollView> 
Verwandte Themen