I have the next layout
And when keyboard comes up, i wan't that green marked part of layout stays always visible. Another words i need to see both EditText and Button.
Here is my code sketch:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="16dp"
tools:context="com.mynfo.concept.auth.AuthActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/titleImageView"
android:layout_gravity="center"
android:src="@drawable/title_auth"
android:layout_weight="0"
android:layout_marginTop="48dp"
android:layout_marginBottom="48dp"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginBottom="8dp"
android:focusable="true"
android:focusableInTouchMode="true"
>
<EditText
android:id="@+id/barcode_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:inputType="number"
android:textColorHint="@color/darker_grey"
android:hint="edittext"
android:maxLength="15"
android:ellipsize="end"
android:ems="10"
android:background="#0000"
android:layout_gravity="left|center_vertical"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_camera"
android:layout_gravity="right|center_vertical"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey"
android:layout_gravity="bottom"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.melnykov.fab.FloatingActionButton
android:id="@+id/button_scan"
android:layout_width="64dp"
android:layout_height="64dp"
fab:fab_colorNormal= "@color/turquoise"
fab:fab_colorPressed= "@color/turquoise_black"
fab:fab_colorRipple= "@color/turquoise_light"
android:src="@android:drawable/ic_menu_camera"
android:layout_gravity="center"/>
</FrameLayout>
<Button
android:id="@+id/button_link_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Authorize"
android:background="@drawable/button_authorize_selector"
android:enabled="false"
android:layout_weight="0"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center">
<TextView
style="@style/TextViewPrimary"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:textSize="16sp"
android:text="Enter your name"
android:gravity="center" />
<com.mynfo.concept.views.FontFitTextView
style="@style/TextViewSecondary"
android:text="And then you will got the access"
android:gravity="center" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/authenticatingView"
android:background="#fff">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:indeterminateOnly="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/authenticatingProgressBar"
android:layout_gravity="center"/>
</FrameLayout>
</FrameLayout>
</LinearLayout>
What haven't worked: adjustPan, adjustSize with or without layout weights.
Maybe I'm doing something wrong?
Thanks for the further help.
P.S. I know that this code feels redundant, but there were some purposes like screen adapting.
In your AndroidMenifest.xml file inside your tag use
windowsSoftInputMode = "adjustResize"
Or take whole layout inside ScrollView
windowsSoftInputMode = "adjustPan"
Example code snippet:
<activity
android:name=".activityname"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan|adjustResize" >
</activity>
Use
android:fillViewport="true"
tag in ScrollView. And to avoid layout size bugs, use margin in Top ScrollView and don't use it in ScrollView child.
And add this in OnCreate
scrollView = (ScrollView) this.findViewById(R.id.scrollView);
scrollView.setVerticalScrollBarEnabled(false);
imageView = (ImageView) findViewById(R.id.imageView);
this.findViewById(android.R.id.content).addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
scrollView.scrollTo(0, imageView.getHeight() + ((ViewGroup.MarginLayoutParams) imageView.getLayoutParams()).topMargin);
}
});
See the comments..