I have a fragment and LinearLayout in my activity. In this fragment I have a textview. If there is no ScrollView in fragment, everything works fine. But if there is ScrollView LinearLayout move to the top of keyboard.
This is how my app looks without Scrollview on the text: https://yapx.ru/v/EPcoQ
And this how it looks with it: https://yapx.ru/v/EPcqd
I don't like that Navigation Bar on the bottom isn't hidden when the keyboard is active. What can I do to make app lok like on the first photo andk make textView scrollable?
I've tried to use "windowSoftInputMode" to forbid keyboard move this LinearLayout, but it didn't helped.
I have also tried "focusableInTouchMode" and "isScrollContainer"
attributes, but they were useless too.
This is the activity file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/main_chetnost"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#86A0FC"
android:windowSoftInputMode="adjustResize"
>
<fragment
android:id="#+id/fragment_theory"
android:name="com.example.user.mathplace_1.theory"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="#+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" />
<fragment
android:id="#+id/fragment_task"
android:name="com.example.user.mathplace_1.Task"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="#+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintVertical_bias="0.0" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="MathPlace"
app:titleTextColor="#fff">
<ImageButton
android:id="#+id/homeButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginStart="8dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="6dp"
android:background="#drawable/home"
android:contentDescription="#string/report_description"
android:onClick="delete"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.887"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.987" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#FFF"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
android:focusableInTouchMode="false"
android:isScrollContainer="false">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#accbff"
android:orientation="horizontal"
android:focusableInTouchMode="false"
android:isScrollContainer="false">
<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusableInTouchMode="false"
android:isScrollContainer="false"/>
</HorizontalScrollView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
And this is the fragment code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:background="#color/background"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditText
android:id="#+id/editText"
android:layout_width="237dp"
android:layout_height="46dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Введите ваш ответ"
android:inputType="number"
android:textColor="#5B6175"
android:textSize="23sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/cardView"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:layout_constraintVertical_bias="0.3" />
<ImageButton
android:id="#+id/send"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/send"
android:onClick="send"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/cardView"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:layout_constraintVertical_bias="0.3" />
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.4">
<ScrollView
android:id="#+id/scrollView4"
android:layout_width="310dp"
android:layout_height="375dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView3"
android:layout_width="310dp"
android:layout_height="375dp"
android:background="#drawable/text_rounded_corner"
android:padding="8dp"
android:text="dddddddddddddddddddddddd"
android:textColor="#5B6175"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/textView"
android:layout_width="310dp"
android:layout_height="47dp"
android:background="#drawable/title_rounded_corner"
android:padding="8dp"
android:text="Заголовок"
android:textColor="#FFF"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="#+id/cardView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="#+id/star2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="44dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
<ImageView
android:id="#+id/star1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
<ImageView
android:id="#+id/star3"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="76dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
</android.support.constraint.ConstraintLayout>
I've found how I can make my text scrollable without breaking old app view.
I just needed to add one line to the java file:
myTextview.setMovementMethod(new ScrollingMovementMethod());
Related
When accessing the page using a Bluetooth keyboard, the Android Tablayout along with its content does not get focused.
But when I am using gesture control it is getting the focus and also can access the contents of the TabItem but when accessing with the external keyboard I am not able to get the focus.
Till now, I tried providing the android:nextFocusRight, android:nextFocusForward but there is no luck that the focus is getting navigated to the desired position.
Below is the XML file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<SurfaceView
android:id="#+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="#+id/graphicOverlayContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_qr_gallery"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="10dp"
android:contentDescription="#string/cl_qr_gallery"
android:nextFocusRight="#id/ll_camera_switch_container"
android:nextFocusDown="#id/ll_camera_switch_container"
android:nextFocusForward="#id/ll_camera_switch_container"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/iv_qr_gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_qr_gallery" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_help"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="10dp"
android:contentDescription="#string/cl_help"
android:nextFocusLeft="#id/tabItemBasic"
android:nextFocusRight="#id/cl_cancel"
android:nextFocusDown="#id/cl_cancel"
android:nextFocusForward="#id/cl_cancel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/iv_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_information" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="#+id/ll_camera_switch_container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:focusable="true"
android:gravity="center_vertical|center_horizontal"
android:nextFocusLeft="#id/cl_qr_gallery"
android:nextFocusRight="#id/cl_help"
android:nextFocusDown="#id/cl_help"
android:nextFocusForward="#id/cl_help"
app:layout_constraintBottom_toBottomOf="#id/cl_help"
app:layout_constraintEnd_toStartOf="#id/cl_help"
app:layout_constraintStart_toEndOf="#id/cl_qr_gallery"
app:layout_constraintTop_toTopOf="parent">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
android:focusable="true"
app:cardCornerRadius="30dp"
app:cardElevation="5dp"
app:strokeColor="#android:color/transparent"
app:strokeWidth="0dp">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tl_barcode_camera_switch"
android:layout_width="match_parent"
android:layout_height="32dp"
android:backgroundTint="#android:color/white"
app:tabBackground="#drawable/tab_selector"
app:tabGravity="fill"
app:tabIndicatorColor="#android:color/transparent"
app:tabIndicatorHeight="0dp"
app:tabMaxWidth="0dp"
app:tabMode="fixed"
app:tabRippleColor="#android:color/transparent"
app:tabSelectedTextColor="#android:color/white"
app:tabTextAppearance="#style/QRCodeSwitchTabLayout"
app:tabTextColor="#color/gray1">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItemAdvanced"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="Advanced View"
android:focusable="true"
android:importantForAccessibility="yes"
android:nextFocusLeft="#id/cl_qr_gallery"
android:nextFocusRight="#id/tabItemBasic"
android:nextFocusForward="#id/tabItemBasic"
android:text="#string/advanced" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItemBasic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="Basic View"
android:focusable="true"
android:importantForAccessibility="yes"
android:nextFocusLeft="#id/tabItemAdvanced"
android:nextFocusRight="#id/cl_help"
android:nextFocusForward="#id/cl_help"
android:text="#string/basic" />
</com.google.android.material.tabs.TabLayout>
</androidx.cardview.widget.CardView>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_cancel"
android:layout_width="0dp"
android:layout_height="60dp"
android:contentDescription="Cancel Button"
android:importantForAccessibility="yes"
android:nextFocusUp="#id/cl_qr_gallery"
android:nextFocusForward="#id/cl_qr_gallery"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_cancel"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="30dp"
android:background="#drawable/bg_qr_code"
android:focusable="false"
android:fontFamily="#font/roboto_medium"
android:importantForAccessibility="no"
android:stateListAnimator="#null"
android:text="#string/cancel"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="16sp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_barcode_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/darker_gray"
android:ellipsize="end"
android:fadingEdge="horizontal|vertical"
android:fontFamily="#font/roboto"
android:gravity="center_vertical|center_horizontal"
android:maxWidth="400dp"
android:maxLines="3"
android:padding="5dp"
android:textColor="#color/cardview_light_background"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Hello I'm trying to make one of my fragment's layout scrollable but can't reach my goal despite having looking for a solution during many hours. I removed all of the layout_constraintBottom_toBottomOf="parent" constraints inside the main constraint layout and also set the height of the layout to wrap_content. Finally I set the fillViewPort attribute of the scrollView to true but the result remains the same. Can someone help me please ?
Here's my .xml file :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/challengeProgressBar"
style="#android:style/Widget.DeviceDefault.Light.ProgressBar.Large"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="300dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/errorImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="300dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/visibleLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/profileNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/profileImageView" />
<ImageView
android:id="#+id/profileImageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginStart="143dp"
android:layout_marginTop="45dp"
android:layout_marginEnd="143dp"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="#tools:sample/avatars" />
<TextView
android:id="#+id/uploadStatusTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toTopOf="#+id/profileImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/nbPointsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:textAppearance="#style/TextAppearance.AppCompat.Display1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/profileNameTextView" />
<Button
android:id="#+id/completedChallengesButton"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="75dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="75dp"
android:text="#string/completed_challenges"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nbPointsTextView" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/completedChallengesRecyclerView"
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginStart="75dp"
android:layout_marginEnd="75dp"
android:background="#drawable/border"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/completedChallengesButton" />
<Button
android:id="#+id/challengesButton"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="75dp"
android:layout_marginEnd="75dp"
android:text="#string/current_challenges"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/completedChallengesRecyclerView" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/challengesRecyclerView"
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginStart="75dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="75dp"
android:background="#drawable/border"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/challengesButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
The cause is using scrollable view (RecyclerView) inside ScrollView, so you should put this one to your RecyclerView
android:nestedScrollingEnabled="false"
But the better solution is make whole screen into only one RecyclerView
I have facing an issue, where my login screen is not scrolling and views are overlapping with button when keyboard shows up.
below is the code for Login layout, can somebody help me why views are getting overlapped
i pasted the login layout file here, Linearlayout at the bottom of the layout file is overlapping with Linearlayout defined justabove it , when Keyboard is opened. and the view is not scrolling.
<data>
<!-- databinding data here -->
</data>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/top_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
<ImageView
android:id="#+id/img_logo_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="#+id/top_guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/txt_title_m_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="#+id/top_guideline" />
<TextView
android:id="#+id/txt_signin_proceed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_title_m_id" />
<RelativeLayout
android:id="#+id/rl_olk_sign"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_signin_proceed">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="#+id/txt_olk_sign"
android:src="#drawable/ic_olk" />
<TextView
android:id="#+id/txt_olk_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"/>
</RelativeLayout>
<TextView
android:id="#+id/txt_no_olk_credentials"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="62dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="62dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rl_olk_sign" />
<TextView
android:id="#+id/txt_term_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="62dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="62dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_no_olk_credentials"/>
<TextView
android:id="#+id/tv_signin_username_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"
android:layout_marginTop="#dimen/_10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_term_login"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:lineHeight="21sp"
android:padding="#dimen/_5dp"/>
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="#+id/txt_signin_proceed">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_layout_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/et_input_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/input_layout_user_name">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/et_input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="#+id/rl_sign_in_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="#dimen/_20dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="42dp"
android:onClick="#{() -> callback.method2()}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/input_layout_password">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"
android:gravity="center"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="#+id/rl_copy_right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/_5dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="#+id/tv_back_to_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:overScrollMode="always"
android:layout_above="#id/tv_copyright_text"/>
<TextView
android:id="#+id/tv_copyright_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:overScrollMode="always"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="visible" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
add this adjustResize to the activity tag in your manifest , then your view will shrink if keyboard opens.
<activity
android:name=".Activities.MyActivity"
android:windowSoftInputMode="adjustResize" ----->this tag
/>
and for your scroll it might help but let me know if it didnt , and post some screenshots of how your view looks.
I have an activity LoginActivity and a fragment SignupSocialFragment.
The fragment is loaded inside of the FrameLayout inside the activity.
The problem is, that the LinearLayout (social_login_footer) in fragment which is constrained to the bottom of its parent is cut of when the fragment is displayed in the activity.
When I add padding/margin to the social_login_footerI can shift it into view but this does not work reliable.
Can anyone help with why the bottom part is cut of?
Shouldnt the ConstraintLayout match the height of its parent FrameLayout.
Code
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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_constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorBlack"
tools:context=".ui.login.LoginActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/login_constraint_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.airbnb.lottie.LottieAnimationView
android:id="#+id/login_lottie_animation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_fileName="background_rotation.json"
app:lottie_loop="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="#+id/login_logo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="true"
android:contentDescription="#string/app_name"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.050000012"
app:srcCompat="#drawable/logo_white" />
<TextView
android:id="#+id/login_logo_subtitle"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="#string/slogan"
android:textColor="#color/colorWhite"
android:textSize="16sp"
android:translationY="-10dp"
app:layout_constraintEnd_toEndOf="#+id/login_logo"
app:layout_constraintStart_toStartOf="#+id/login_logo"
app:layout_constraintTop_toBottomOf="#id/login_logo" />
<FrameLayout
android:id="#+id/login_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
app:layout_constraintTop_toBottomOf="#+id/login_logo_subtitle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
fragment_login_social.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="#300000CC "
android:paddingStart="32dp"
android:paddingEnd="32dp"
tools:context=".ui.login.SignupSocialFragment">
<TextView
android:id="#+id/login_social_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="32dp"
android:fontFamily="#font/montserrat_light"
android:text="#string/login_subtitle"
android:textAlignment="center"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="#+id/social_login_email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/social_login_email"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="#string/email_signup_btn"
app:layout_constraintBottom_toTopOf="#+id/social_login_facebook"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_social_text" />
<Button
android:id="#+id/social_login_facebook"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
app:icon="#drawable/facebook_logo"
app:iconGravity="textStart"
app:layout_constraintBottom_toTopOf="#+id/social_login_google"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/social_login_email" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/social_login_google"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_marginTop="16dp"
android:background="#color/colorWhite"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/social_login_facebook">
<TextView
android:id="#+id/social_login_google_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="#string/google_signup_btn"
android:textColor="#android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/social_login_google_logo"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:src="#drawable/googleg_standard_color_18"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/social_login_google_txt"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="#+id/social_login_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="4dp"
android:text="#string/already_member"
android:textSize="16sp"
android:clickable="true"
android:focusable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/social_login_google" />
<LinearLayout
android:id="#+id/social_login_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="#+id/login_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_version"
android:layout_marginEnd="4dp"
android:textSize="12sp" />
<TextView
android:id="#+id/login_policy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="#string/privacy_link"
android:textSize="12sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Layout blueprints
Rendered on Nexus 5X API 28
After wasting some hours of my precious lifetime I have finally found it.
The problem is caused by the ImageViews android:adjustViewBounds="true" attribute.
After removing it everything works as expected.
Try adding android:fitsSystemWindows="true" to fragment_login_social.xml first child view
I'm facing a strange situation, I have designed a fragment to include a ScrollView but when i go to another fragment and back from backstack
View is Converted to another view not ScrollView and screen items overlaps
fragment XML:
<android.support.constraint.ConstraintLayout 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:gravity="center"
tools:context="com.eh.waseldriver.TripDetailsFragment"
tools:layout_editor_absoluteY="25dp">
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/trip_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></include>
<Button
android:id="#+id/btn_cancel_trip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:background="#drawable/withoutbackgroundcolor"
android:gravity="center"
android:padding="10dip"
android:text="طلب إلغاء الرحله"
android:textColor="#color/md_white_1000"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/recy_decoming_trips"
app:layout_constraintVertical_bias="1.0" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recy_decoming_trips"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/include"
app:layout_constraintEnd_toEndOf="#+id/include"
app:layout_constraintStart_toStartOf="#+id/include"
app:layout_constraintTop_toBottomOf="#+id/include" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
and the below xml code is the another fragment design
<android.support.constraint.ConstraintLayout 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"
tools:context="com.eh.waseldriver.ReportFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="من فضلك إدخل التفاصيل التى تود الابلاغ عنها"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/et_report"
android:layout_width="268dp"
android:layout_height="123dp"
android:layout_marginTop="48dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
<Button
android:id="#+id/bt_send_report"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginBottom="8dp"
android:background="#drawable/edittext_style"
android:text="إرسال"
android:textColor="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
Note that ConstraintLayout Tag is closed but not appearing on the above
also you could check this GIF to see what happens it may help in investigating what is the wrong
GIF Link
I want to know the cause and how to solve it