2016-08-06 11 views
12

मैं लेआउट पर काम कर रहा हूं जहां मैंने स्क्रीन के केंद्र पर एक cardview संरेखित किया है और स्क्रीन के नीचे button पर हमसे संपर्क करें। कुंजीपटल बंद होने पर यह लेआउट ठीक दिखता है।कुंजीपटल खोलने पर पैरेंट सेंटर लेआउट व्यू के साथ अभिभावक नीचे के दृश्य छुपाएं

यह नीचे की तरह दिखता है: - enter image description here

layout.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

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

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

       <ImageView 
        android:id="@+id/login_image" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="@drawable/login_background" /> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="@color/grey_background" /> 

      </LinearLayout> 


      <android.support.v7.widget.CardView 
       android:id="@+id/media_card_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:layout_marginLeft="24dp" 
       android:layout_marginRight="24dp" 
       card_view:cardBackgroundColor="@color/white" 
       card_view:cardElevation="4dp" 
       card_view:cardCornerRadius="5dp" 
       > 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 

        > 

        <ImageView 
         android:id="@+id/logoImageView" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:background="@color/grey_background" 
         android:padding="15dp" 
         android:src="@drawable/logo_login" 
         /> 

        <EditText 
         android:id="@+id/usertext" 
         android:layout_width="match_parent" 
         android:layout_height="40dp" 
         android:layout_below="@id/logoImageView" 
         android:layout_marginLeft="20dp" 
         android:layout_marginRight="20dp" 
         android:layout_marginTop="20dp" 
         android:background="@drawable/edittext_background" 
         android:hint="User ID" 
         android:maxLength="50" 
         android:padding="10dp" 
         android:singleLine="true" 
         android:textColorHint="@color/hint_text_color" 
         android:textSize="16sp" /> 


        <FrameLayout 
         android:id="@+id/passwordLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/usertext" 
         android:layout_marginTop="8dp" 
         android:orientation="horizontal"> 

         <EditText 
          android:id="@+id/passtext" 
          android:layout_width="match_parent" 
          android:layout_height="40dp" 
          android:layout_marginLeft="20dp" 
          android:layout_marginRight="20dp" 
          android:background="@drawable/edittext_background" 
          android:fontFamily="sans-serif" 
          android:hint="@string/password" 
          android:inputType="textPassword" 
          android:maxLength="50" 
          android:padding="10dp" 
          android:singleLine="true" 
          android:textColorHint="@color/hint_text_color" 
          android:textSize="16sp" /> 

         <ImageView 
          android:id="@+id/passwordeye" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right|center_vertical" 
          android:padding="8dp" 
          android:layout_marginRight="25dp" 
          android:src="@drawable/eye_close" /> 

        </FrameLayout> 

        <LinearLayout 
         android:id="@+id/termsLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/passwordLayout" 
         android:layout_marginLeft="15dp" 
         android:layout_marginRight="20dp" 
         android:layout_marginTop="15dp" 
         android:gravity="center" 
         android:orientation="horizontal"> 


         <ImageView 
          android:id="@+id/check_box" 
          android:layout_width="wrap_content" 

          android:layout_height="wrap_content" 
          android:padding="5dp" 
          android:src="@drawable/checkbox_checked" /> 

         <TextView 
          android:id="@+id/terms_and_cond" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="5dp" 
          android:textColor="@color/black" 
          android:textColorLink="#80000000" 
          android:textSize="13sp" /> 
        </LinearLayout> 

        <View 
         android:id="@+id/lineView" 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:layout_below="@id/termsLayout" 
         android:layout_marginTop="15dp" 
         android:background="@color/grey_background" /> 

        <LinearLayout 
         android:id="@+id/newuser_login_layout" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:background="@color/dark_grey" 
         android:layout_below="@id/lineView" 
         android:orientation="horizontal"> 


         <TextView 
          android:id="@+id/newUserButton" 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:background="@drawable/translucent_round_button" 
          android:gravity="center" 
          android:text="New User ?" 
          android:textColor="@color/grey_text_color" 
          android:textSize="17sp" /> 

         <TextView 
          android:id="@+id/loginbutton" 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:background="@drawable/bottom_round_button" 
          android:gravity="center" 
          android:text="Login" 
          android:textColor="@color/white" 
          android:textSize="17sp" /> 

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

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:layout_gravity="center" 
       android:gravity="center" 
       android:orientation="vertical"> 


       <TextView 
        android:id="@+id/contactus_button" 
        android:layout_width="wrap_content" 
        android:layout_height="35dp" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="15dp" 
        android:background="@drawable/contact_us_selector" 
        android:drawableLeft="@drawable/contact_us_green" 
        android:drawablePadding="5dp" 
        android:gravity="center" 
        android:padding="8dp" 
        android:text="Contact Us" 
        android:textColor="@color/black" /> 

       <TextView 
        android:id="@+id/textviewone" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="10dp" 
        android:layout_marginLeft="15dp" 
        android:layout_marginRight="15dp" 
        android:gravity="center" 
        android:textColor="@color/black" 
        android:textColorLink="#80000000" 
        android:textSize="13sp" /> 

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

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/snackbarCoordinatorLayout" 
     android:layout_width="match_parent" 

     android:layout_height="match_parent" 
     > 

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

    <ProgressBar 
     android:id="@+id/progressBar" 
     style="?android:attr/android:progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:visibility="gone" /> 
</FrameLayout> 

प्रश्न: -

जब कीबोर्ड फिर हमें button संपर्क करें और पाठ जो ऊपर स्क्रीन छिपाने के नीचे स्थित है खुलता है केंद्र लेआउट के पीछे। मैं चाहता हूं कि इसे छिपाना नहीं चाहिए, कीबोर्ड स्क्रीन खोलने पर स्क्रॉल होना चाहिए और हमसे संपर्क करें button नीचे होना चाहिए।

enter image description here

+0

क्या आपके पास इसके साथ खेलने के लिए जिथब या बिटबकेट पर कोड नहीं है? :-) बस सभी संसाधनों के साथ इस गतिविधि की जरूरत है। – piotrek1543

उत्तर

0
अपने scrollview में

एंड्रॉयड जोड़ें: isScrollContainer = "false" विशेषता

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:isScrollContainer="false"> 

</ScrollView> 
+0

काम नहीं कर रहा है .. नीचे के विचार अभी भी छुपा रहे हैं। –

0

बस एक पंक्ति जोड़े जाने के लिए ... -:

कीबोर्ड खोलने पर यह कैसा दिखता

अपनी मेनिफेस्ट फ़ाइल की आवश्यक गतिविधि में android:windowSoftInputMode="stateHidden|adjustPan" जोड़ें।

+0

मेरे लिए काम नहीं किया –

0

समस्या यहां है कि आपके CardViewandroid:layout_centerInParent="true" है, और अपने LinearLayout युक्त "हमसे संपर्क करें" सामान android:layout_alignParentBottom="true" है।

मैं आपके लेआउट पर पुनर्विचार करता हूं, यह थोड़ा गन्दा है, लेकिन शायद आप LinearLayout में के साथ android:layout_alignParentBottom="true" को प्रतिस्थापित कर सकते हैं।

+0

'एंड्रॉइड: layout_below =" @ + id/media_card_view "' काम नहीं कर रहा है :(। अभी भी पैरेंट नीचे लेआउट छुपा रहा है –

0

यहाँ मेरी लेआउट है:

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

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

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

       <ImageView 
        android:id="@+id/login_image" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="@android:color/holo_blue_bright"/> 

       <View 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="@android:color/darker_gray"/> 

      </LinearLayout> 


      <android.support.v7.widget.CardView 
       android:id="@+id/media_card_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:layout_marginLeft="24dp" 
       android:layout_marginRight="24dp" 
       card_view:cardBackgroundColor="@android:color/white" 
       card_view:cardCornerRadius="5dp" 
       card_view:cardElevation="4dp" 
       > 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 

        > 

        <ImageView 
         android:id="@+id/logoImageView" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:background="@android:color/darker_gray" 
         android:padding="15dp" 
         /> 

        <EditText 
         android:id="@+id/usertext" 
         android:layout_width="match_parent" 
         android:layout_height="40dp" 
         android:layout_below="@id/logoImageView" 
         android:layout_marginLeft="20dp" 
         android:layout_marginRight="20dp" 
         android:layout_marginTop="20dp" 
         android:background="@android:drawable/editbox_background" 
         android:hint="User ID" 
         android:maxLength="50" 
         android:padding="10dp" 
         android:singleLine="true" 
         android:textColorHint="@color/colorPrimaryDark" 
         android:textSize="16sp"/> 


        <FrameLayout 
         android:id="@+id/passwordLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/usertext" 
         android:layout_marginTop="8dp" 
         android:orientation="horizontal"> 

         <EditText 
          android:id="@+id/passtext" 
          android:layout_width="match_parent" 
          android:layout_height="40dp" 
          android:layout_marginLeft="20dp" 
          android:layout_marginRight="20dp" 
          android:background="@android:drawable/editbox_background" 
          android:fontFamily="sans-serif" 
          android:hint="Password" 
          android:inputType="textPassword" 
          android:maxLength="50" 
          android:padding="10dp" 
          android:singleLine="true" 
          android:textColorHint="@color/colorPrimaryDark" 
          android:textSize="16sp"/> 

         <ImageView 
          android:id="@+id/passwordeye" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_gravity="right|center_vertical" 
          android:layout_marginRight="25dp" 
          android:padding="8dp" 
          android:src="@android:drawable/ic_menu_edit"/> 

        </FrameLayout> 

        <LinearLayout 
         android:id="@+id/termsLayout" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/passwordLayout" 
         android:layout_marginLeft="15dp" 
         android:layout_marginRight="20dp" 
         android:layout_marginTop="15dp" 
         android:gravity="center" 
         android:orientation="horizontal"> 


         <ImageView 
          android:id="@+id/check_box" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:padding="5dp" 
          android:src="@android:drawable/checkbox_on_background"/> 

         <TextView 
          android:id="@+id/terms_and_cond" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="5dp" 
          android:textColor="@android:color/black" 
          android:textColorLink="#80000000" 
          android:textSize="13sp"/> 
        </LinearLayout> 

        <View 
         android:id="@+id/lineView" 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:layout_below="@id/termsLayout" 
         android:layout_marginTop="15dp" 
         android:background="@android:color/darker_gray"/> 

        <LinearLayout 
         android:id="@+id/newuser_login_layout" 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:layout_below="@id/lineView" 
         android:background="@android:color/darker_gray" 
         android:orientation="horizontal"> 


         <TextView 
          android:id="@+id/newUserButton" 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:gravity="center" 
          android:text="New User ?" 
          android:textColorHint="@android:color/darker_gray" 
          android:textSize="17sp"/> 

         <TextView 
          android:id="@+id/loginbutton" 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1" 
          android:gravity="center" 
          android:text="Login" 
          android:textColor="@android:color/white" 
          android:textSize="17sp"/> 

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

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignBottom="@id/media_card_view" 
       android:orientation="vertical" 
       android:layout_alignParentBottom="true" 
       android:layout_centerHorizontal="true" 
       android:gravity="center_horizontal" 
       android:layout_below="@+id/media_card_view"> 

       <TextView 
        android:id="@+id/textView" 
        android:layout_width="wrap_content" 
        android:layout_height="35dp" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="15dp" 
        android:drawableLeft="@android:drawable/sym_contact_card" 
        android:drawablePadding="5dp" 
        android:padding="8dp" 
        android:text="Contact Us" 
        android:textColor="@android:color/black" 
        android:layout_gravity="center"/> 


       <TextView 
        android:id="@+id/textviewone" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_marginBottom="10dp" 
        android:layout_marginLeft="15dp" 
        android:layout_marginRight="15dp" 
        android:gravity="center_horizontal" 
        android:text="Copyright by piotrek1543 @2016" 
        android:textColor="@android:color/black" 
        android:textColorLink="#80000000" 
        android:textSize="13sp"/> 
      </LinearLayout> 
     </RelativeLayout> 
    </ScrollView> 


    <ProgressBar 
     android:id="@+id/progressBar" 
     style="?android:attr/android:progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:visibility="gone"/> 

</FrameLayout> 

यहाँ यह कैसा दिखाई देता है कुंजीपटल

और बाद खोलने से पहले:

सबसे पहले, खोलने के अपने AndroidManifest और अपने LoginActivity अनुभाग इस लाइन डाल में:

 android:windowSoftInputMode="stateVisible|adjustResize"> 

के बाद कि आपकी Activity प्रकट तरह दिखना चाहिए:

<activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar" 
     android:windowSoftInputMode="stateVisible|adjustResize"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 

      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </activity> 

फिर संशोधित textoneview और textview1 के साथ आपके LinearLayout इस तरह के फ़ील्ड:

 <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@id/media_card_view" 
      android:orientation="vertical" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:gravity="center_horizontal" 
      android:layout_below="@+id/media_card_view"> 

      <TextView 
       android:id="@+id/textView" 
       android:layout_width="wrap_content" 
       android:layout_height="35dp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="15dp" 
       android:drawableLeft="@android:drawable/sym_contact_card" 
       android:drawablePadding="5dp" 
       android:padding="8dp" 
       android:text="Contact Us" 
       android:textColor="@android:color/black" 
       android:layout_gravity="center"/> 


      <TextView 
       android:id="@+id/textviewone" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="10dp" 
       android:layout_marginLeft="15dp" 
       android:layout_marginRight="15dp" 
       android:gravity="center_horizontal" 
       android:text="Copyright by piotrek1543 @2016" 
       android:textColor="@android:color/black" 
       android:textColorLink="#80000000" 
       android:textSize="13sp"/> 
     </LinearLayout> 

आशा है कि यह मदद मिलेगी

संपादित: यदि आप अपने LinearLayout की BottomSheetStyle छोड़ने के लिए आप इस कोड का उपयोग कर सकते हैं करना चाहते हैं:

 <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignBottom="@id/media_card_view" 
      android:orientation="vertical" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:gravity="center_horizontal|bottom" 
      app:layout_behavior="@string/bottom_sheet_behavior" 
      > 

      <TextView 
       android:id="@+id/textView" 
       android:layout_width="wrap_content" 
       android:layout_height="35dp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="45dp" 
       android:layout_marginBottom="15dp" 
       android:drawableLeft="@android:drawable/sym_contact_card" 
       android:drawablePadding="5dp" 
       android:padding="8dp" 
       android:text="Contact Us" 
       android:textColor="@android:color/black" 
       android:gravity="center" 
       android:layout_gravity="center"/> 


      <TextView 
       android:id="@+id/textviewone" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="10dp" 
       android:layout_marginLeft="15dp" 
       android:layout_marginRight="15dp" 
       android:gravity="center_horizontal" 
       android:text="Copyright by piotrek1543 @2016" 
       android:textColor="@android:color/black" 
       android:textColorLink="#80000000" 
       android:textSize="13sp"/> 
     </LinearLayout> 
तो

ऐसा लगता होगा जैसे:

लेकिन बाद में आप अपने कीबोर्ड खोलने आप देखना होगा

आपका "हमसे संपर्क करें" CardView के पीछे छिपा हो जाएगा। यदि आप TextView दोनों media_card_view के आकार को कम करने के बारे में सोचना चाहते हैं। मेरे लिए दोनों दृश्य दृश्यमान होने के लिए बहुत बड़ा है।

0

तुम बस अपने कोड में कुछ पंक्ति जोड़ें

प्रकट फ़ाइल:

<activity 
     android:name=".activities.LoginActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" 
     android:windowSoftInputMode="stateHidden|adjustResize" /> 

आप के साथ तो प्रोग्राम के तरह पृष्ठभूमि की जांच करें

getWindow().setBackgroundDrawableResource(R.drawable.app_bg) ; 
0

से कम सेट स्क्रॉल तो समस्या पृष्ठभूमि सेट किया है इस। मुझे यकीन नहीं है कि यह मदद करेगा या नहीं।

ScrollView view = (ScrollView)findViewById(R.id.scrollView); 
view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); 
view.setFocusable(true); 
view.setFocusableInTouchMode(true); 
view.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     v.requestFocusFromTouch(); 
     return false; 
    } 
}); 
0

मैं LinearLayout कि हमसे संपर्क करें बटन और इसे से android:layout_alignParentBottom="true" को दूर करने में शामिल है में android:layout_below="@id/media_card_view" डालने की कोशिश करेंगे।

इसके अलावा आप मुख्य रिलेवेटिवआउट में android:layout_height="wrap_content" सेट कर सकते हैं और यदि उस लेआउट में इसका उपयोग नहीं किया जाता है तो शायद कोऑर्डिनेटरलाइट को हटा दें।

उम्मीद है कि यह मदद करता है;)

संबंधित मुद्दे