2017-03-20 2 views
0

image which looks goodScrollview mit Knopf an der Unterseite des Bildschirms

but here button leaves actual position

ich habe eine Scroll-Ansicht für die Formulardaten verwenden und eine Schaltfläche, die an einem unteren Rand des Bildschirms sein sollte. Ich habe es erreicht. aber das Problem ist, wenn der EditText fokussiert wird und die Tastatur geöffnet wird, bleibt die Schaltfläche nicht unten auf dem Bildschirm, sondern direkt über der Android-Tastatur. Ich möchte, dass es auch dann unten ist, wenn die Tastatur geöffnet ist oder nicht.

Ich habe versucht, die android:fillViewport="true" mit Bildlaufansicht, aber es gibt keine ordnungsgemäße Ausgabe.

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

      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/lout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 


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

       <LinearLayout 
        android:id="@+id/fout" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        android:paddingBottom="16dp" 
        android:paddingTop="10dp"> 

        <ImageView 
         android:id="@+id/fimg" 
         android:layout_width="match_parent" 
         android:layout_height="250dp" 
         android:src="@drawable/addimg" /> 

        <android.support.design.widget.TextInputLayout 
         android:id="@+id/vsubcusine" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:paddingBottom="10dp" 
         android:paddingLeft="5dp" 
         android:paddingRight="5dp" 
         android:paddingTop="10dp" 
      > 

         <EditText 
          android:id="@+id/add_food_title" 
          style="@style/textbox" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:hint="Title for Food" 
          android:inputType="text" 

          /> 
        </android.support.design.widget.TextInputLayout> 

        <android.support.design.widget.TextInputLayout 
         android:id="@+id/vcusine" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:hint="cusine" 
         android:paddingBottom="10dp" 
         android:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         android:paddingTop="0dp"> 

         <Spinner 
          android:id="@+id/cusine" 
          style="@style/textbox" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:background="#fff" 
          android:padding="10dp" /> 
        </android.support.design.widget.TextInputLayout> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 
         android:paddingBottom="10dp" 
         android:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         android:paddingTop="10dp"> 


         <RadioGroup 
          android:id="@+id/isveg" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:orientation="horizontal" 
          android:paddingLeft="20dp"> 

          <RadioButton 
           android:id="@+id/veg" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_weight="2" 
           android:text="Veg" /> 

          <RadioButton 
           android:id="@+id/nonveg" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:layout_weight="2" 

           android:text="Non-Veg" /> 

         </RadioGroup> 
        </LinearLayout> 

        <android.support.design.widget.TextInputLayout 
         android:id="@+id/vfprice" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:paddingBottom="0dp" 
         android:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         android:paddingTop="0dp" 
         > 

         <EditText 
          android:id="@+id/fprice" 
          style="@style/textbox" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:hint="price" 
          android:inputType="number" /> 


        </android.support.design.widget.TextInputLayout> 
       </LinearLayout> 
      </ScrollView> 


      <LinearLayout 
       android:id="@+id/t" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:gravity="center" 
       android:orientation="horizontal" 
       android:weightSum="2"> 

       <Button 
        android:id="@+id/foodadd" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_margin="10dp" 
        android:layout_weight="1" 
        android:background="@drawable/button" 
        android:text="ADD FOOD" 
        android:textColor="#FFF" 
        android:textStyle="bold" /> 
      </LinearLayout> 

     </RelativeLayout> 
+0

Verwenden Sie LinearLayout anstelle von RelativeLayout als übergeordnetes Element. – tahsinRupam

+0

@TahsinRupam diese Lösung funktioniert nicht, es zeigt keine Schaltfläche auf dem Bildschirm überhaupt –

+0

Es braucht auch einige Anpassungen, kann ich hinzufügen, erfordern Modifikationen mit Screenshot, wenn Sie möchten. – tahsinRupam

Antwort

2

In manifest, Just Add android:windowSoftInputMode="adjustPan" auf Ihre entsprechende Aktivität tag:

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

Ausgang:

enter image description here

Hoffnung, das hilft.

+0

ja es funktioniert für mich danke –

+0

Es ist mir ein Vergnügen. :) – tahsinRupam

Verwandte Themen