2016-05-10 13 views
0

Ich habe die Anzahl der Edit-Texte in der Layout-Datei, die Soft-Tastatur deckt einige der Texte bearbeiten. Ich möchte ganze Edit-Texte nach oben scrollen, wenn der Benutzer auf den ersten Text klickt, damit alle Felder gleichzeitig sichtbar sind. Ich habe versucht, ScroolView, isScrollContainer, Ausrichtung: vertikal, requestFocus, android: imeOptions = "flagNoFullscreen" in XML-Datei und Android: windowSoftInputMode = "adjustPan | adjustResize" in Manifest hinzugefügt. Aber nicht die erwarteten Ergebnisse. hier ist meine XML-DateiSoft-Tastatur abdecken EditText Felder android

<?xml version="1.0" encoding="utf-8"?> 
<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" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:background="@drawable/register_back" 
tools:context="com.example.RegisterActivity"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/registerFieldsRL" 
    android:layout_marginTop="40dp"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/header" 
     android:text="Register" 
     android:textAllCaps="true" 
     android:textColor="#646b99" 
     android:textSize="18dp" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" /> 
    <EditText 
     android:id="@+id/nameET" 
     android:hint="Enter Your Name" 
     android:layout_below="@+id/header" 
     style="@style/editTextStyle" 
     android:layout_marginTop="10dp" 
     android:singleLine="true"/> 
    <EditText 
     android:id="@+id/emailET" 
     android:hint="Enter Your Email Id" 
     android:layout_below="@+id/nameET" 
     style="@style/editTextStyle" 
     android:layout_marginTop="5dp" 
     android:singleLine="true"/> 

    <EditText 
     android:id="@+id/mobileET" 
     android:hint="Enter Your Mobile Number" 
     android:layout_below="@+id/emailET" 
     style="@style/editTextStyle" 
     android:layout_marginTop="5dp" 
     android:singleLine="true"/> 
    <EditText 
     android:id="@+id/passwordET" 
     android:hint="Enter Password" 
     android:layout_below="@+id/mobileET" 
     style="@style/editTextStyle" 
     android:layout_marginTop="5dp" 
     android:singleLine="true"/> 
    <EditText 
     android:id="@+id/confrm_passwordET" 
     android:hint="Re-enter Password" 
     android:layout_below="@+id/passwordET" 
     style="@style/editTextStyle" 
     android:layout_marginTop="5dp" 
     android:singleLine="true"/> 
    <Button 
     android:layout_width="200dp" 
     android:layout_height="40dp" 
     android:id="@+id/logon_button" 
     android:text="Logon" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" 
     android:layout_below="@+id/confrm_passwordET" 
     android:layout_marginTop="7dp" 
     android:background="#db96a3" 
     android:textColor="#e8d3c1"/> 
</RelativeLayout> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/social_loginsRL" 
    android:layout_alignParentBottom="true" 
    android:layout_marginBottom="30dp"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/social_login_header" 
     android:text="- OR LOGIN WITH -" 
     android:layout_centerHorizontal="true" 
     android:textColor="#646b99" 
     android:textSize="18dp"/> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_below="@+id/social_login_header" 
     android:layout_marginTop="10dp"> 
     <Button 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/facebook_button" 
      android:background="@drawable/fbbutton" 
      android:layout_toLeftOf="@+id/social_login_split_view"/> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/social_login_split_view"></View> 
     <Button 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/gmail_button" 
      android:background="@drawable/gmailbutton" 
      android:layout_toRightOf="@+id/social_login_split_view" /> 
    </RelativeLayout> 

</RelativeLayout> 

und hier ist mein Style code

<style name="editTextStyle"> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:background">@drawable/edittext_background</item> 
    <item name="android:gravity">center_horizontal</item> 
    <item name="android:backgroundTint">#e8d3c1</item> 
    <item name="android:textColor">#646b99</item> 
</style> 

und das ist mein Drawable Datei

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:drawable="@drawable/patient_details_et_background"/> 
    <item> 
     <shape> 
     <stroke 
      android:width="1dp" 
      android:color="#d4c6c1" /> 
     <padding 
      android:left="10dp" 
      android:top="10dp" 
      android:right="10dp" 
      android:bottom="10dp" /> 
     </shape> 
    </item> 
    </selector> 
+0

Wenn Sie 'Scroll View' verwendet haben, sollte es praktikabel sein. Was ist das Problem bei der Verwendung? –

+0

googlebutton und facebook button decken den Rest des edittext ab, nur zwei edittext Felder sind sichtbar. – Tara

+0

Also sind alle Ihre 5 'Texte bearbeiten 'nicht scrollbar? –

Antwort

0

Tara , von dem, was ich von Ihrer Frage verstehe (vielleicht bin ich falsch), dass Sie alle Texte in Ihrem Layout bearbeiten möchten, um nach oben zu scrollen und im Fokus zu sein, wenn Sie einen Klick auf einen der EditText erhalten?

Lassen Sie sagen 10 EditText der in Ihrem Layout haben, und Benutzer klickt auf den ersten ein, wenn alle EditText die Scroll-up, an dem das Element der Benutzer auch von Fokus bewegt geklickt. Dies wäre nicht gut für den Benutzer, da sie nicht in der Lage sind, das Feld zu bearbeiten, auf das sie geklickt haben.

Für das Problem würde ich sagen, alle Ihre EditText in eine ScrollView und setzen Sie ein Attribut, Android: fillViewport = "true" in der Bildlaufansicht. Dadurch wird das Problem nicht gelöst, Sie können jedoch die gesamte Länge und die Elemente in der Bildlaufansicht im Vorschaufenster anzeigen.

Das Soft-Schlüsselwort wird einen Teil des Bildschirms abdecken, sobald es geöffnet ist, aber Sie sollten sicherstellen, dass der Benutzer über jede Ansicht in Ihrem Layout scrollen kann.

+0

Ich habe bereits die Bildlaufansicht hinzugefügt und kann auch scrollen. Ich habe 5 redigieren Text in meinem Layout, Anforderung ist Benutzer sollte in der Lage, alle 5 Text zu sehen, wie es etwas Platz an der Spitze ist, weiche Tastatur deckt Hälfte des letzten Textes bearbeiten. Das ist mein Problem. – Tara