this is my xml file layout when keyboard is open my bottom view also scroll
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_school"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/_14sdp"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:hint="School Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/edt_education_degree"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Degree" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_field_of_study"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Field Of Study" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="wrap_content"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_start_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Start Date"
android:inputType="number"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_end_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="End Date"
android:inputType="number"
android:textColor="#2e2e2e"
android:imeOptions="actionNext"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_education_activities"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#2e2e2e"
android:textSize="#dimen/_14sdp"
android:imeOptions="actionNext"
android:hint="Activities" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_education_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/button_selector"
android:text="Save"
android:visibility="gone"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/tv_delete_education"
android:layout_width="match_parent"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentBottom="true"
android:layout_marginTop="#dimen/_10sdp"
android:gravity="center"
android:visibility="gone"
android:textColor="#222222"
android:textSize="#dimen/_16sdp"
android:text="Delete Education" />
when i open the keyboard my textview (tv_delete_education) is override on text
i want to fix my textview in bottom navigation no required to scroll. i also add in menifest file adjustPan ,adjustResize but still not work for me if any kind of help let me know thanks in advance
use this in android manifest android:windowSoftInputMode="adjustNothing"
for activity.It will solve your problem.
Here is basic format for your design and its working.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.example.whiz_010.myapplication.ui.home.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Company"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Location"
/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Start Date"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="End Date"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Delete Experience"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
AndroidManifest.xml
<activity
android:name=".ui.home.MainActivity"
android:windowSoftInputMode="adjustPan"/>
Related
I want the screen to automatically scroll up when the keyboard opens, so that the user can see what he has written.
The solution I found was to change the manifest and use adjustPan or adjustResize. I used both of them but it still didn't work.
Where is my mistake?
Thanks in advance.
xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
tools:context=".auth.LoginActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="#mipmap/img_login"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
tools:ignore="MissingConstraints" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
android:orientation="vertical"
android:background="#drawable/login_back">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="#color/customColor"
android:gravity="center"
android:textSize="30dp"
android:layout_marginTop="42dp"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:focusableInTouchMode="true"
android:hint="User Name"
android:layoutDirection="rtl"
android:textColorHint="#color/customColor"
>
<EditText
android:id="#+id/acLogin_edtUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:inputType="textEmailAddress"
android:textSize="16dp"
android:singleLine="true"
android:textColor="#color/customColor"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:focusableInTouchMode="true"
android:hint="Password"
android:layoutDirection="rtl"
android:textColorHint="#color/customColor"
>
<EditText
android:id="#+id/acLogin_edtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textSize="16dp"
android:textColor="#color/customColor"
/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="42dp"
android:layout_gravity="center"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="#color/customColor"
app:cardCornerRadius="8dp">
<TextView
android:id="#+id/acLogin_txtLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Login"
android:textColor="#ffffff"
android:textSize="18dp" />
<ProgressBar
android:id="#+id/acLogin_prgLoading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="gone" />
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="48dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Don't have any account?"
android:gravity="bottom"
android:layout_marginLeft="58dp"
android:textColor="#color/customColor"
android:textSize="16dp"/>
<TextView
android:id="#+id/acLogin_txtSignUp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:gravity="bottom"
android:text="Sign Up"
android:textColor="#color/customColor"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="200dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I change manifest to:
<activity android:name=".auth.LoginActivity"
android:windowSoftInputMode="adjustPan | adjustResize"/>
In my Android app, I am trying to get the birthday of the user. Below is my XML document .
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/colorPurple"
app:popupTheme="#style/AppTheme.PopupOverlay"
style="#style/MyDrawerArrowToggle"
android:layout_marginTop="#dimen/toolbar_layout_top_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="30dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="#+id/signUp_back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_arrow_white" />
</LinearLayout>
<LinearLayout
android:layout_width="220dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20dp"
android:text="#string/birthday"
android:textColor="#color/colorWhite"
android:gravity="center|left"
android:paddingLeft="20dp"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textStyle="bold"
android:text="#string/what_is_your_birthday"
android:gravity="center"
android:layout_marginTop="60dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp">
<DatePicker
android:layout_width="match_parent"
android:layout_height="150dp"
android:datePickerMode="spinner"
android:id="#+id/date_picker"/>
<!--<com.aigestudio.wheelpicker.widgets.WheelDayPicker-->
<!--android:layout_width="50dp"-->
<!--android:layout_height="match_parent" />-->
<!--<com.aigestudio.wheelpicker.widgets.WheelMonthPicker-->
<!--android:layout_width="50dp"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginLeft="20dp"/>-->
<!--<com.aigestudio.wheelpicker.widgets.WheelYearPicker-->
<!--android:layout_width="50dp"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginLeft="20dp"/>-->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#color/colorPurple"
android:layout_marginTop="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="#+id/signup_birthday_next_button_layout">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text = "#string/next_text"
android:textColor="#color/colorWhite"
android:textSize="14dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
This gives me the below UI
But I am looking for the below
How can I get the second UI?
Please add this xml file it may be help full to solve your problem.
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:gravity="center"
android:id="#+id/btnNotification"
android:text="What is your birthday"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<DatePicker
android:id="#+id/spinnerDatePicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:datePickerMode="spinner"
android:descendantFocusability="blocksDescendants"
android:focusable="true"
android:spinnersShown="true" />
<Button
android:text="next"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
You can use SpinnerDatePicker open source library it has UI like below
As it is open source you can change if you need.
When I click on my fragment's edittext (all of them), it immediatelly loses its focus. I realized the focus is moving to the home button but I don't how to prevent that. I already tried android:windowSoftInputMode="adjustPan" in the manifest but it doesn't work.
It only happens on my Galaxy Tab with android 6.0.
Here's my layout xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/planning_editor_layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/planning_editor_scrollview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
style="#style/AppTheme.ViewLayout"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:minHeight="#dimen/view_size_large"
android:orientation="horizontal"
android:padding="#dimen/margin_small">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_xsmall"
android:gravity="center_horizontal"
android:orientation="vertical">
<br.com.elleveresultados.widget.ListItemTextView
android:id="#+id/planning_editor_textview_service_initials"
style="#style/AppTheme.TextView.ListItem"
android:alpha="#integer/alpha_secondary"
android:textColor="?android:textColorPrimaryInverse" />
<ImageView
android:id="#+id/planning_editor_imageview_status"
android:layout_width="#dimen/spinner_icon_size"
android:layout_height="#dimen/spinner_icon_size"
android:layout_marginTop="#dimen/margin_xsmall"
android:contentDescription="#string/planning_list_item_imageview_status" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
android:paddingEnd="#dimen/margin"
android:paddingStart="#dimen/margin">
<br.com.elleveresultados.widget.Spinner
android:id="#+id/planning_editor_spinner_service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:gravity="start"
android:hint="#string/planning_editor_spinner_service"
android:src="#drawable/ic_edit_black_18dp"
android:textAppearance="#style/TextAppearance.AppTheme.Large" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<br.com.elleveresultados.widget.Spinner
android:id="#+id/planning_editor_spinner_track"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:gravity="start"
android:hint="#string/planning_editor_spinner_track"
android:src="#drawable/ic_edit_black_18dp"
android:textAppearance="#style/TextAppearance.AppTheme.Body2" />
<br.com.elleveresultados.widget.Spinner
android:id="#+id/planning_editor_spinner_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:enabled="false"
android:gravity="start"
android:hint="#string/planning_editor_spinner_direction"
android:src="#drawable/ic_edit_black_18dp"
android:textAppearance="#style/TextAppearance.AppTheme.Body2" />
</LinearLayout>
<br.com.elleveresultados.widget.Spinner
android:id="#+id/planning_editor_spinner_lane"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:gravity="start"
android:hint="#string/planning_editor_spinner_lane"
android:src="#drawable/ic_edit_black_18dp"
android:textAppearance="#style/TextAppearance.AppTheme.Body1" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="#dimen/margin"
android:layout_marginTop="#dimen/margin"
android:background="#color/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/margin_small">
<br.com.elleveresultados.widget.DropDown
android:id="#+id/planning_editor_dropdown_concessionaire"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="#string/planning_editor_spinner_concessionaire" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:orientation="horizontal">
<br.com.elleveresultados.widget.DropDown
android:id="#+id/planning_editor_dropdown_state"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:enabled="false"
android:hint="#string/planning_editor_spinner_state" />
<br.com.elleveresultados.widget.DropDown
android:id="#+id/planning_editor_spinner_road"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:enabled="false"
android:hint="#string/planning_editor_spinner_road" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small"
android:orientation="horizontal">
<br.com.elleveresultados.widget.DropDown
android:id="#+id/planning_editor_dropdown_contractor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:enabled="false"
android:hint="#string/planning_editor_spinner_contractor" />
<br.com.elleveresultados.widget.DropDown
android:id="#+id/planning_editor_dropdown_lot"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:enabled="false"
android:hint="#string/planning_editor_spinner_lot" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:baselineAligned="false"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_initial_km">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_initial_km"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="3"
android:nextFocusForward="#+id/planning_editor_edittext_initial_m" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_initial_m">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_initial_m"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="4"
android:nextFocusForward="#+id/planning_editor_edittext_final_km" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small"
android:baselineAligned="false"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_final_km">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_final_km"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="3"
android:nextFocusForward="#+id/planning_editor_edittext_final_m" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_final_m">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_final_m"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="4"
android:nextFocusForward="#+id/planning_editor_edittext_lane_width" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:baselineAligned="false"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_lane_length">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_lane_length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_lane_width">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_lane_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:imeOptions="actionDone"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small"
android:baselineAligned="false"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/planning_editor_layout_quantity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_quantity">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_small"
android:layout_weight="1"
android:hint="#string/planning_editor_edittext_date">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="date" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<br.com.elleveresultados.widget.EditText
android:id="#+id/planning_editor_edittext_justification"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_large"
android:layout_weight="0.9"
android:gravity="start|top"
android:inputType="textMultiLine"
android:maxLength="255"
android:maxLines="4"
android:scrollbars="vertical"
tools:ignore="LabelFor" />
<ImageView
android:id="#+id/planning_editors_imageview_save_justification"
style="#style/AppTheme.ImageView.Clickable"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.1"
android:contentDescription="#string/planning_editor_iamgeview_justification"
android:src="#drawable/ic_done_all_accent_24dp" />
</LinearLayout>
<fragment
android:id="#+id/planning_editor_fragment_attachment"
android:name="br.com.elleveresultados.widget.PhotoAttachment"
android:layout_width="match_parent"
android:layout_height="#dimen/view_size_large"
tools:layout="#layout/widget_photo_attachment" />
</LinearLayout>
</LinearLayout>
<com.github.clans.fab.FloatingActionMenu
android:id="#+id/planning_editor_fam_validation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/fab_size"
fab:menu_animationDelayPerItem="50"
fab:menu_colorNormal="#color/grey_300"
fab:menu_colorPressed="#color/black_tertiary"
fab:menu_fab_label="#string/planning_list_item_imageview_status"
fab:menu_fab_size="normal"
fab:menu_icon="#drawable/ic_remove"
fab:menu_labels_colorRipple="#66FFFFFF"
fab:menu_labels_cornerRadius="3dp"
fab:menu_labels_ellipsize="none"
fab:menu_openDirection="down"
tools:ignore="RelativeOverlap">
<com.github.clans.fab.FloatingActionButton
android:id="#+id/planning_editor_fab_confirmed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_done_primary_18dp"
fab:fab_colorNormal="#color/grey_300"
fab:fab_colorPressed="#color/black_tertiary"
fab:fab_size="mini" />
<com.github.clans.fab.FloatingActionButton
android:id="#+id/planning_editor_fab_not_confirmed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_clear_red_18dp"
fab:fab_colorNormal="#color/grey_300"
fab:fab_colorPressed="#color/black_tertiary"
fab:fab_size="mini" />
</com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>
</ScrollView>
<android.support.design.widget.AppBarLayout
android:id="#+id/planning_editor_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:theme="#style/AppTheme.AppBarOverlay">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/appbar_elevation"
android:background="#drawable/appbar_top_shadow" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/planning_editor_appbar_layout_view"
android:layout_width="match_parent"
android:layout_height="#dimen/tab_layout_size"
android:background="#android:color/white"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="#+id/planning_editor_textview_last_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:alpha="#integer/alpha_secondary"
android:gravity="center"
android:textColor="#color/black_primary" />
<br.com.elleveresultados.widget.Tab
android:id="#+id/planning_editor_tab_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:alpha="#integer/alpha_secondary"
android:src="#drawable/ic_edit_black_24dp"
android:text="#string/planning_editor_tab_edit"
android:textColor="#color/black_primary" />
</LinearLayout>
<LinearLayout
android:id="#+id/planning_editor_appbar_layout_edit"
android:layout_width="match_parent"
android:layout_height="#dimen/tab_layout_size"
android:background="#android:color/white"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<br.com.elleveresultados.widget.Tab
android:id="#+id/planning_editor_tab_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:alpha="#integer/alpha_secondary"
android:src="#drawable/ic_cancel_black_24dp"
android:text="#string/planning_editor_tab_cancel"
android:textColor="#color/black_primary" />
<br.com.elleveresultados.widget.Tab
android:id="#+id/planning_editor_tab_save"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:alpha="#integer/alpha_secondary"
android:src="#drawable/ic_save_black_24dp"
android:text="#string/planning_editor_tab_save"
android:textColor="#color/black_primary" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Thank you.
i have 2 different XML files. One is signup.xml the other chat.xml, both constructed with the PercentageLayout library.
the signup.xml works great - opening keyboard doesnt change any view.
However, in chat.xml whenever i pop the keyboard the view shrinks or out of screen, and i dont know why since i constructed them both nearly in the same manner, only i suspect that because i use ScrollView this happens.
The problematic layout, chat.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout
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">
<!-- top -->
<LinearLayout
android:id="#+id/top"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="100%"
app:layout_heightPercent="8%"
android:background="#075607"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#acddf4"
android:textSize="20sp"
android:text="jfioewjfoiewjfoi"
android:gravity="center"
android:layout_gravity="center_horizontal|center_vertical" />
</LinearLayout>
<!-- Mid -->
<LinearLayout
android:id="#+id/mid"
android:layout_below="#+id/top"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="100%"
app:layout_heightPercent="84%"
android:background="#b1b7b3"
android:orientation="vertical">
<ScrollView
android:id="#+id/scroller"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#drawable/chat_bg" >
<LinearLayout
android:id="#+id/chatWindowContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
<!-- Bottom -->
<LinearLayout
android:id="#+id/bottom"
android:layout_below="#+id/mid"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="100%"
app:layout_heightPercent="8%"
android:background="#000000"
android:orientation="horizontal">
<EditText
android:id="#+id/etMessage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:paddingLeft="5dp"
android:background="#drawable/text"
android:imeOptions="actionNone"
android:inputType="textMultiLine"
android:singleLine="false" />
<Button
android:id="#+id/bSendMessage"
android:layout_width="40dp"
android:layout_height="match_parent"
android:background="#drawable/ic_send"
android:layout_gravity="right" />
</LinearLayout>
And the working layout, signup.xml :
<LinearLayout
android:id="#+id/title"
android:layout_height="0dp"
android:layout_width="0dp"
app:layout_heightPercent="15%"
app:layout_widthPercent="100%">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/signup"/>
</LinearLayout>
<LinearLayout
android:id="#+id/mid"
android:orientation="vertical"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_below="#+id/title"
app:layout_heightPercent="35%"
app:layout_widthPercent="100%"
android:baselineAligned="true">
<!-- Username -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%">
<ImageView
android:layout_width="35dp"
android:layout_height="wrap_content"
android:src="#drawable/person" />
<EditText
android:id="#+id/etUsername_signup"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ems="10"
android:inputType="text"
android:text="test"
android:textColor="#000000"
android:paddingLeft="5dp"
android:layout_weight="0.1"
android:background="#drawable/text">
<requestFocus />
</EditText>
</LinearLayout>
<!-- Email -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%">
<ImageView
android:layout_width="35dp"
android:layout_height="wrap_content"
android:src="#drawable/email" />
<EditText
android:id="#+id/etEmail_signup"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ems="10"
android:inputType="textEmailAddress"
android:text="email#address.com"
android:textColor="#000000"
android:paddingLeft="5dp"
android:layout_weight="0.1"
android:background="#drawable/text"/>
</LinearLayout>
<!-- Password1 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%">
<ImageView
android:layout_width="35dp"
android:layout_height="wrap_content"
android:src="#drawable/password" />
<EditText
android:id="#+id/etPassword1_signup"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ems="10"
android:inputType="textPassword"
android:text="pass"
android:textColor="#000000"
android:paddingLeft="5dp"
android:layout_weight="0.1"
android:background="#drawable/text"/>
</LinearLayout>
<!-- Password2 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
app:layout_heightPercent="20%"
app:layout_widthPercent="20%">
<ImageView
android:layout_width="35dp"
android:layout_height="wrap_content"
android:src="#drawable/password" />
<EditText
android:id="#+id/etPassword2_signup"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ems="10"
android:inputType="textPassword"
android:text="pass"
android:textColor="#000000"
android:paddingLeft="5dp"
android:layout_weight="0.1"
android:background="#drawable/text"/>
</LinearLayout>
<!-- Spinner and RadioGroup-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Spinner
android:layout_width="100dp"
android:layout_height="match_parent"
android:id="#+id/spinner"
android:layout_gravity="center" />
<RadioGroup
android:id="#+id/rgRadius"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Kilometer" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mile" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
<!-- Image -->
<LinearLayout
android:id="#+id/image"
android:orientation="vertical"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_below="#+id/mid"
app:layout_heightPercent="40%"
app:layout_widthPercent="100%"
android:baselineAligned="true">
<ImageView
android:id="#+id/imgProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/faceless" />
</LinearLayout>
<!-- Button -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_heightPercent="10%"
app:layout_widthPercent="100%"
android:orientation="vertical"
android:layout_below="#id/image">
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:id="#+id/bSignup"
android:layout_gravity="center|bottom"
android:background="#drawable/button_send" />
</LinearLayout>
Use relative layout solve your shrinking layout problem I tested following layout.
Add following entry with activity tag : android:windowSoftInputMode="adjustResize"
And Your layout
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<!-- top -->
<LinearLayout
android:id="#+id/top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#075607"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#acddf4"
android:textSize="20sp"
android:text="jfioewjfoiewjfoi"
android:gravity="center"
android:layout_gravity="center_horizontal|center_vertical" />
</LinearLayout>
<!-- Mid -->
<LinearLayout
android:id="#+id/mid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom"
android:layout_below="#+id/top"
android:background="#b1b7b3"
android:orientation="vertical">
<ScrollView
android:id="#+id/scroller"
android:layout_width="match_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/chatWindowContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
<!-- Bottom -->
<LinearLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<EditText
android:id="#+id/etMessage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:paddingLeft="5dp"
android:imeOptions="actionNone"
android:inputType="textMultiLine"
android:singleLine="false" />
<Button
android:id="#+id/bSendMessage"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_gravity="right" />
</LinearLayout>
</RelativeLayout>
I'm trying to center my layout so there's an equal amount of space on the right and left side. Currently, everything is left aligned. I've tried setting layout_gravity to center_horizontal for all my widgets/elements but that doesn't work. Can someone explain what I'm doing wrong? Here's my code:
<FrameLayout 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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center_horizontal">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/scored"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/percent"
android:textSize="20sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
<EditText
android:id="#+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="5"
android:inputType="number" />
</TableRow>
</TableLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/calculate" />
</LinearLayout>
</FrameLayout>
You can remove all other gravity attributes you set.
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"> <---- HERE