2016-08-04 31 views
0

Ich habe drei EditText in meinem Layout. Wenn ich auf eines von ihnen klicke, verkleinert es mein Layout und das zweite Layout ist kaum sichtbar. Ich möchte, dass, wenn ich auf das zweite Layout klicke ("Liebe Eltern"), die Tastatur den letzten Edittext (Name des Lehrers) überlappen sollte und wenn ich auf den letzten Editiertext klicke, sollte er über der Tastatur erscheinen. Hier sind die ScreenshotsTastatur schrumpfen EditText

enter image description here enter image description here

und hier ist der Code

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/actionbar_title_color" 
    android:orientation="vertical"> 

    <include 
     android:id="@+id/include" 
     layout="@layout/toolbar" /> 

    <android.support.v7.widget.CardView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="25dp" 
     android:layout_marginLeft="25dp" 
     android:layout_marginRight="25dp" 
     android:layout_marginTop="25dp" 
     card_view:cardElevation="10sp" 
     card_view:cardUseCompatPadding="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

      android:background="#ffffff" 
      android:orientation="horizontal"> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_marginTop="10dp" 
       android:layout_weight="1" 
       android:background="@drawable/filebinder" /> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="14" 
       android:orientation="vertical"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        android:layout_marginRight="10dp" 
        android:orientation="horizontal"> 


        <LinearLayout 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="6" 
         android:orientation="vertical"> 

         <TextView 
          android:id="@+id/dateDiary" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="10dp" 
          android:fontFamily="sans-serif" 
          android:text="30 July" 
          android:textColor="#03a9f4" 
          android:textSize="20sp" /> 

         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="1dp" 
          android:layout_marginBottom="10dp" 
          android:background="#03a9f4" /> 

        </LinearLayout> 

        <LinearLayout 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:background="@drawable/diarybookmark" /> 

       </LinearLayout> 

       <ScrollView 
        android:id="@+id/scrollView" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="10dp"> 

        <EditText 
         android:id="@+id/diaryHeading" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center_horizontal" 
         android:layout_margin="10dp" 
         android:ems="5" 
         android:fontFamily="sans-serif" 
         android:hint="Diary Heading" 
         android:inputType="textPersonName" 
         android:textAlignment="center" 
         android:textColor="#000000" 
         android:textSize="18sp" /> 
       </ScrollView> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 


        <EditText 
         android:id="@+id/diaryTeacherName" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentBottom="true" 
         android:layout_gravity="center" 
         android:fontFamily="sans-serif" 
         android:hint="Teacher\'s Name..." 
         android:textSize="16sp" /> 


        <at.markushi.ui.CircleButton 
         android:id="@+id/addDiaryEntry" 
         android:layout_width="74dip" 
         android:layout_height="74dip" 
         android:layout_gravity="right" 
         android:src="@drawable/ic_action_tick" 
         app:cb_color="@color/actionbar_title_color" 
         app:cb_pressedRingWidth="8dip" 
         android:layout_alignParentBottom="true" 
         android:layout_alignParentRight="true" 
         android:layout_alignParentEnd="true" /> 

        <EditText 
         android:id="@+id/diaryContent" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_above="@+id/addDiaryEntry" 
         android:layout_alignLeft="@+id/scrollView" 
         android:layout_alignStart="@+id/scrollView" 
         android:layout_alignTop="@+id/scrollView" 
         android:fontFamily="sans-serif" 
         android:gravity="top" 
         android:hint="Enter Diary Note...\n\n\n\n" 
         android:text="Dear Parents," 
         android:textSize="14sp" /> 


       </RelativeLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 

und hier ist mein Manifest

<activity 
      android:name=".DiaryEntry.DiaryEntryTeacherActivity" 
      android:label="DiaryEntry" 
      android:windowSoftInputMode="adjustResize" 
      android:theme="@style/AppTheme.NoActionBar"></activity> 
+1

haben Sie versucht, die Kindansicht von 'CardView' als' ScrollView' hinzuzufügen? – Sanoop

+0

Nein, ich denke, ich sollte das versuchen .. – Shubh

Antwort

0

Sie müssen ScrollView wie verwenden;

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/actionbar_title_color" 
    android:orientation="vertical"> 

    <include 
     android:id="@+id/include" 
     layout="@layout/toolbar" /> 

    <ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true"> 

     <android.support.v7.widget.CardView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="25dp" 
      android:layout_marginLeft="25dp" 
      android:layout_marginRight="25dp" 
      android:layout_marginTop="25dp" 
      card_view:cardElevation="10sp" 
      card_view:cardUseCompatPadding="true"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 

       android:background="#ffffff" 
       android:orientation="horizontal"> 

       <LinearLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_marginTop="10dp" 
        android:layout_weight="1" 
        android:background="@drawable/filebinder" /> 

       <LinearLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="14" 
        android:orientation="vertical"> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="5dp" 
         android:layout_marginRight="10dp" 
         android:orientation="horizontal"> 


         <LinearLayout 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="6" 
          android:orientation="vertical"> 

          <TextView 
           android:id="@+id/dateDiary" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_marginTop="10dp" 
           android:fontFamily="sans-serif" 
           android:text="30 July" 
           android:textColor="#03a9f4" 
           android:textSize="20sp" /> 

          <LinearLayout 
           android:layout_width="match_parent" 
           android:layout_height="1dp" 
           android:layout_marginBottom="10dp" 
           android:background="#03a9f4" /> 

         </LinearLayout> 

         <LinearLayout 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="1" 
          android:background="@drawable/diarybookmark" /> 

        </LinearLayout> 

        <ScrollView 
         android:id="@+id/scrollView" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_margin="10dp"> 

         <EditText 
          android:id="@+id/diaryHeading" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center_horizontal" 
          android:layout_margin="10dp" 
          android:ems="5" 
          android:fontFamily="sans-serif" 
          android:hint="Diary Heading" 
          android:inputType="textPersonName" 
          android:textAlignment="center" 
          android:textColor="#000000" 
          android:textSize="18sp" /> 
        </ScrollView> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:orientation="vertical"> 


         <EditText 
          android:id="@+id/diaryTeacherName" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentBottom="true" 
          android:layout_gravity="center" 
          android:fontFamily="sans-serif" 
          android:hint="Teacher\'s Name..." 
          android:textSize="16sp" /> 


         <at.markushi.ui.CircleButton 
          android:id="@+id/addDiaryEntry" 
          android:layout_width="74dip" 
          android:layout_height="74dip" 
          android:layout_gravity="right" 
          android:src="@drawable/ic_action_tick" 
          app:cb_color="@color/actionbar_title_color" 
          app:cb_pressedRingWidth="8dip" 
          android:layout_alignParentBottom="true" 
          android:layout_alignParentRight="true" 
          android:layout_alignParentEnd="true" /> 

         <EditText 
          android:id="@+id/diaryContent" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_above="@+id/addDiaryEntry" 
          android:layout_alignLeft="@+id/scrollView" 
          android:layout_alignStart="@+id/scrollView" 
          android:layout_alignTop="@+id/scrollView" 
          android:fontFamily="sans-serif" 
          android:gravity="top" 
          android:hint="Enter Diary Note...\n\n\n\n" 
          android:text="Dear Parents," 
          android:textSize="14sp" /> 


        </RelativeLayout> 
       </LinearLayout> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 
    </ScrollView> 
</LinearLayout>