Inserting progressbar on button click - android

I have this XML and I'm planning that when the login button is clicked, it disappears and the progress bar shows up. how can I do it? this is the image of the XML already made. I've tried dozen of layout edits but still cannot achieve such. I hope someone could help as soon as possible. If there are any suggestions that you can tell please do help.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/logregbackground"
tools:context=".Login.LoginRegister">
<ImageView
android:id="#+id/mainformBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="#drawable/darkbackground" />
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="#drawable/isalonlogowithoutbackground"
android:id="#+id/mainformLogo"
android:scaleType="fitCenter"
android:layout_marginBottom="30dp"
/>
<ScrollView
android:id="#+id/scrollviewid"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content"
android:layout_below="#id/mainformLogo"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/trans_white_rectangle"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome to iSalon"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Style on the go, Wherever you go"
android:textColor="#color/white"
android:textSize="12sp"
android:layout_marginBottom="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Email/Username"
android:background="#drawable/rounded_white"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:drawableLeft="#drawable/ic_user_icon"
android:textSize="14sp"
android:drawablePadding="5dp"
android:paddingStart="10dp"
android:id="#+id/loginUser"
android:layout_marginBottom="10dp"
android:paddingLeft="10dp" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="Password"
android:background="#drawable/rounded_white"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:drawableLeft="#drawable/ic_pass_icon"
android:textSize="14sp"
android:inputType="textPassword"
android:drawablePadding="5dp"
android:paddingStart="10dp"
android:id="#+id/loginPass"
android:paddingLeft="10dp" />
<Button
android:id="#+id/buttonLogin"
android:layout_width="150dp"
android:layout_height="match_parent"
android:textColor="#color/white"
android:text="Login"
android:textStyle="normal"
android:layout_gravity="center"
android:background="#drawable/login_button"
android:layout_marginTop="16dp"
android:padding="8dp"
/>
<ProgressBar
android:id="#+id/loadinglogin"
android:layout_width="124dp"
android:layout_height="27dp"
android:layout_marginLeft="100dp"
android:background="#color/white" />
<Button
android:id="#+id/buttonRegister"
android:layout_width="150dp"
android:layout_marginTop="10dp"
android:layout_height="match_parent"
android:textColor="#color/white"
android:layout_gravity="center"
android:text="Register"
android:background="#drawable/register_button"
android:padding="8dp"
android:layout_marginBottom="16dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

If you don't want the progress bar to be visible at first, you need to give it a "gone" visibility attribute in the layout (or in your onCreate code):
android:visibility="gone"
That would explain why your progress bar is visible before the login button is clicked.
If your login button isn't disappearing when it's clicked, I don't know why. You'd probably have to show your code.

Related

ImageView as background being pushed up by opening keyboard

As I'm using png as a background for my View I didn't want it to stretch in a weird way. So I put an ImageView inside RelativeLayout and set its parametrs to match parent.
The problem appears when I click on a edittext and keyboard is opening. android:windowSoftInputMode="adjustResize" and keyboard pushes every view inside relative layout up, so my background image moves to. Do you know how to fix this?
Basically I want to adjust the view but not background image.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/login_relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:hapticFeedbackEnabled="false"
tools:context="com.example.radzik.recipes.activity.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/background_activity_login" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:gravity="center_horizontal">
<ProgressBar
android:id="#+id/progress_bar_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<LinearLayout
android:id="#+id/login_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="#+id/progress_bar_login"
android:orientation="vertical">
<TextView
android:id="#+id/text_view_email_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="EMAIL"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_email_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:hint="example#gmail.com"
android:inputType="textEmailAddress"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white" />
<TextView
android:id="#+id/text_view_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="15dp"
android:elevation="0dp"
android:fontFamily="#string/roboto_thin_typeface_asset_path"
android:text="PASSWORD"
android:textColor="#color/white_transparent"
android:textSize="12sp" />
<EditText
android:id="#+id/edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/text_view_password"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:backgroundTint="#android:color/transparent"
android:fontFamily="#string/roboto_condensed_typeface_asset_path"
android:inputType="textPassword"
android:paddingBottom="5dp"
android:paddingTop="0dp"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white"
android:textSize="30sp" />
<Space
android:layout_width="1dp"
android:layout_height="20dp" />
<Button
android:id="#+id/button_sign_in"
style="?android:textAppearanceSmall"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_sign_in"
android:onClick="onLoginClicked"
android:padding="10dp"
android:text="Log In"
android:textColor="#android:color/white"
android:textStyle="bold" />
<Space
android:layout_width="1dp"
android:layout_height="35dp" />
<!--<Button-->
<!--android:id="#+id/button_facebook_sign_in"-->
<!--style="?android:textAppearanceSmall"-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="fill_parent"-->
<!--android:background="#color/colorPrimaryDark"-->
<!--android:onClick="onFacebookLogInClicked"-->
<!--android:padding="10dp"-->
<!--android:layout_marginLeft="10dp"-->
<!--android:layout_marginRight="10dp"-->
<!--android:text="Login with Facebook"-->
<!--android:textStyle="bold"-->
<!--android:textColor="#color/colorText"/>-->
<com.facebook.login.widget.LoginButton
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textStyle="bold"
/>
<!-- <Button
android:id="#+id/button_facebook_login"
android:layout_width="350dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_facebook_log_in"
android:drawableLeft="#drawable/facebook_white_logo_custom_1"
android:paddingLeft="10dp"
android:paddingRight="36dp"
android:text="Facebook"
android:textColor="#android:color/white"
android:textStyle="bold" /> -->
<Space
android:layout_width="1dp"
android:layout_height="10dp" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
app:srcCompat="#drawable/login_bottom_coloured_line" />
<Button
android:id="#+id/button_sign_up"
style="?android:textAppearanceSmall"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#040C12"
android:onClick="onSignUpClicked"
android:padding="10dp"
android:text="SIGN UP"
android:textColor="#android:color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Background image:
background image
Try this:
Put you ImageView inside scrollview.
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="#drawable/background_activity_login"/>
</ScrollView>
And in java set scrollview enabled false in onCreate method like below:
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView);
scrollView.setEnabled(false);
Try not to add background in scroll view add another layout for background after scrollview it work for me

Move Layout Up when Soft Keyboard appears

I have login page with Email Id ,Password & LOGIN button. Right now when any one of the Edit Text gain focus then system keyboard hides my Login button. I want to push my layout above when keyboard appears keeping LOGIN button above of keyboard.
P.S I've tried all solution like
adjust Pan|adjust Resize, adjust Pan,adjust Resize"
in manifest as well as in Java code
But none of thing worked for me.
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/newl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dp"
android:drawablePadding="8dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_clock"
android:id="#+id/clock"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timetracker"
android:fontFamily="LucidaGrande"
android:textSize="30dp"
android:textAlignment="center"
android:layout_marginTop="15dp"
android:layout_gravity="center_horizontal"
android:id="#+id/tt"
android:layout_below="#+id/clock"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:layout_below="#+id/tt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
>
<ImageView
android:layout_marginLeft="7dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_person_black_24dp"
android:layout_centerVertical="true"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
android:layout_marginLeft="9dp"
android:drawablePadding="12dp"
android:textSize="15dp"
android:layout_marginRight="45dp"
android:fontFamily="Sans Serif"
android:layout_centerInParent="true"
android:textColor="#FFFFFF"
android:background="#android:color/transparent"
android:id="#+id/spinner2"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_drop_down_black_24dp"
android:layout_alignParentRight="true"
android:paddingRight="8dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<View
android:layout_below="#+id/rel"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/lock"
android:drawablePadding="12dp"
android:layout_marginTop="30dp"
android:layout_below="#+id/rel"
android:layout_marginRight="7dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="7dp"
android:hint="Password"
android:background="#android:color/transparent"
android:textColorHint="#FFFFFF"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:id="#+id/editText"
android:inputType="textPassword"
android:backgroundTint="#FFFFFF"
/>
<View
android:layout_below="#+id/editText"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_below="#+id/editText"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="#FFFFFF"
android:text="LOG IN"
android:id="#+id/log"
android:textColor="#D04045"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
The solution was to use android:fillViewport="true" on the ScrollView.
and with this you can also use android:windowSoftInputMode="adjustResize"
this worked for me
try this,
Add the below line in your manifest file,
android:windowSoftInputMode="adjustResize"
For example,
<activity android:name=".Game" android:windowSoftInputMode="adjustResize">
</activity>

android:gravity in TextView not working

When i apply android:gravity to center(or even textAlignment true for TextView) , the instant changes are applied to current activity (using my device for testing) and the text is centered .
But then when i install/restart app with the same changes (or come back to present activity from previous one), the text is left aligned at the start of the TextView .
TextView trying to center : android:id="#+id/ttamt
The text is centered only when i make changes while running app on the activity.
Really can't understand what wrong i am doing here ,
Thanks for your time and help .
Following is my layout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/mainRel"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#5f5f5f"
android:elevation="10dp"
android:transitionName="#string/transtrans">
<ImageView
android:id="#+id/ttimg"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="#drawable/com_facebook_tooltip_blue_topnub"
android:transitionName="timgTrans" />
<TextView
android:id="#+id/ttamt"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/ttimg"
android:layout_marginTop="20dp"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="1001"
android:textColor="#fff"
android:textSize="55sp"
android:textStyle="bold|italic"
android:transitionName="tamtTrans" />
<TextView
android:id="#+id/ttdate"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/ttamt"
android:layout_marginTop="25dp"
android:layout_toRightOf="#+id/timg"
android:fontFamily="sans-serif"
android:text="01/01/01"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="22dp"
android:textStyle="bold|italic" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#f0f0f0"
android:clickable="true"
android:elevation="15dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/ttdesc"
android:layout_width="150dp"
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:text="TestDesc"
android:textSize="16sp"
android:textStyle="bold|italic"
android:transitionName="tdescTrans" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="120dp"
android:src="#drawable/ic_mode_edit_black_24dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#f0f0f0"
android:clickable="true"
android:elevation="15dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="7dp">
<TextView
android:id="#+id/ttmsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:lineSpacingExtra="5dp"
android:text="View SMS"
android:textSize="15dp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Looks like an issue with api 18 or higher after seeing this answer.
Did the same , wrapped my views inside LinearLayout and used textAlignment="center" . Works fine now .
Final Layout Snippet :
<RelativeLayout
android:id="#+id/mainRel"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#5f5f5f"
android:elevation="10dp"
android:transitionName="#string/transtrans">
<ImageView
android:id="#+id/ttimg"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="#drawable/com_facebook_tooltip_blue_topnub"
android:transitionName="timgTrans" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:orientation="vertical">
<TextView
android:id="#+id/ttamt"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/ttimg"
android:fontFamily="sans-serif"
android:text="1001"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="55sp"
android:textStyle="bold|italic"
android:transitionName="tamtTrans" />
<TextView
android:id="#+id/ttdate"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/ttamt"
android:layout_marginTop="25dp"
android:fontFamily="sans-serif"
android:text="01/01/01"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="22dp"
android:textStyle="bold|italic" />
</LinearLayout>
</RelativeLayout>

Android:placing layouts over each other

i am having an issue in over-lapping layouts,i am trying to implement an login form with in the entire page , and a button at the bottom , when the user press this button a registration form slides from bottom to up , my problems are:the first the registration form push the entire screen (i want it to overflow), the second: that i have 2 buttons with a shape background that appears on the top of registration form and the login inputs remains active
my xml code
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/content_login_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
tools:context="com.example.a3wd.mytest10.LoginPage"
tools:showIn="#layout/activity_login_page">
<ImageView
android:id="#+id/login2Logo"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:contentDescription="#string/fixawy_logoPic"
android:src="#drawable/logo2" />
<LinearLayout
android:id="#+id/loginInputs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login2Logo"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:layout_width="140dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:text="#string/loginText"
android:textColor="#color/loginText"
android:textSize="24sp"
android:textStyle="bold" />
<EditText
android:id="#+id/userEmail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/myspinner"
android:hint="#string/nameHint"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="#+id/userPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/myspinner"
android:hint="#string/passwordHint"
android:inputType="textPassword"
android:padding="10dp"
android:textAlignment="textEnd" />
</LinearLayout>
<Button
android:id="#+id/loginBtn"
android:layout_width="96dp"
android:layout_height="56dp"
android:layout_below="#id/loginInputs"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/shape_round_corner"
android:text="#string/enterBtnTxt"
/>
<TextView
android:id="#+id/passwordText"
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_alignBaseline="#id/loginBtn"
android:layout_alignParentRight="true"
android:layout_below="#id/loginInputs"
android:layout_marginRight="50dp"
android:text="#string/forgetPassword"
android:textColor="#color/loginText"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/facebookTxt"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="#id/loginBtn"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/facebookTxt"
android:textSize="18sp" />
<Button
android:id="#+id/facebookBtn"
android:layout_width="88dp"
android:layout_height="32dp"
android:layout_below="#id/facebookTxt"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/facebookbtn"
android:text="#string/facebook_btn"
android:textColor="#ffffff" />
<TextView
android:id="#+id/newUserTxt"
android:layout_width="140dp"
android:layout_height="20dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="#string/newUserTxt"
android:textSize="18sp"
android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_above="#+id/registrationBtn"
/>
<Button
android:id="#id/registrationBtn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/register_btn_shape"
android:gravity="right"
android:onClick="registerFragment"
android:layout_alignParentBottom="true"
android:paddingEnd="40dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/registerForm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/newUserTxt"
android:background="#drawable/register_back"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="right"
android:paddingEnd="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"
/>
</LinearLayout>
</RelativeLayout>
and the java code for animation
Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.bottom_up);
registrationForm.startAnimation(bottomUp);
registrationForm.setVisibility(View.VISIBLE);
this is the original view
and this is an image of the problem

Partial UI screen up

In a screen, I have a edit text on top (large contains space for 4-5 line), image view below that and submit button at bottom. on Keyboard up it should not hide my submit button.
when keyboard appears i am able to resize the window using android:windowSoftInputMode="adjustResize" which allow me not to hide the submit button but it resize my image also which i don't want.
Only submit button should move up when keyboard is visible without resizing image.
I tried frame layout also but it didn't may be i tried wrong way. Any help will be appriciated.
Apply this and let me know is it still happening or not .
activity_mian.xml
<ScrollView 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:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/xxx.jpg"
android:orientation="vertical"
tools:context=".LoginActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="20dp"
android:src="#drawable/logo_app" />
<EditText
android:id="#+id/edtEmail"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/login_textbox"
android:ems="10"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#ffffff"
android:textCursorDrawable="#null" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/edtPassword"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_textbox"
android:ems="10"
android:hint="Password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#ffffff"
android:textCursorDrawable="#null" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/edtPassword"
android:layout_marginTop="2dp" />
</RelativeLayout>
<CheckBox
android:id="#+id/checkBox_remember"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:button="#drawable/checkbox_selector"
android:checked="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:text=" Remember Me"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<Button
android:id="#+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="top|center_vertical|center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/btn_login" />
</LinearLayout>
</LinearLayout>
</ScrollView>
set your Button, EditText etc.. inside one linear layout followed by one parent ScrollView .
one another thing is that set android:windowSoftInputMode="stateAlwaysHidden"
inside your java file where your xml file is bind .
With some changes in #jigs answer i got it working and posting may be it can help others like me
1) Root layout as normal in my case Relative layout. Then scroll view inside scroll view take a Linear layout where specify edit text + image View. Then bottom button.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="#android:color/white"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollViewNotScrollable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/user_name_container">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
>
<EditText
android:id="#+id/input_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#00000000"
android:ellipsize="start"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="start|center_vertical"
android:hint="#string/feed_hint"
android:imeActionLabel="Submit"
android:imeOptions="actionSend"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="25dp"
android:textColor="#color/feed_sub_color"
android:textColorHint="#color/light_gray"
android:textCursorDrawable="#null" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<!--<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:padding="4dp"
android:layout_centerHorizontal="true"
>-->
<ImageView
android:id="#+id/imgPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:background="#android:color/white"
android:elevation="5dp"
android:padding="4dp"
android:visibility="gone" />
<!--</ScrollView>-->
<ImageView
android:id="#+id/close_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imgPreview"
android:layout_marginLeft="-45dp"
android:layout_marginTop="-20dp"
android:layout_toRightOf="#+id/imgPreview"
android:elevation="5dp"
android:paddingBottom="15dp"
android:src="#drawable/closeimage"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/user_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<EditText
android:id="#+id/feed_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#null"
android:ellipsize="end"
android:fontFamily="san-serif-condensed"
android:padding="12dp"
android:singleLine="true"
android:text="sherry's phone"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_name_size"
android:visibility="gone" />
<TextView
android:id="#+id/feed_user_name_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#null"
android:ellipsize="end"
android:fontFamily="san-serif-condensed"
android:padding="12dp"
android:paddingLeft="20dp"
android:singleLine="true"
android:text="sherry's phone"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_name_size" />
<ImageView
android:id="#+id/edit_name"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:scaleType="centerInside"
android:src="#drawable/editname" />
<Button
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_corner_update_block"
android:fontFamily="san-serif-medium"
android:text="Done"
android:textColor="#android:color/white"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
2)android:windowSoftInputMode="adjustResize" in your manifest.xml
3) disable scroll in java code (optional)
mScrollView.setOnTouchListener( new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event)
{
return true;
}
});

Categories

Resources