My English is poor. So I threw off the video. I think any programmer looking at this will understand the reason. Thank you in advance
I want to learn how to use ReleaseativeLayout correctly, because ConstainLayout is very buggy. Even using it in Android Studio Canary.
So I'm using ReleativeLayout and LineartLayout now. These are the most effective ViewGroup. I thought. But it turned out all wrong
XML Code
<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"
android:gravity="center"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>
Just add one more Relative Layout below of your parent layout and set Gravity to it
<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"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<RelativeLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
</RelativeLayout>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
Only parent layout height and width would match parent instead of a child.
you've have entered FrameLayout height="match_parent"
you've to implement like this.
<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"
android:gravity="center"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:background="#drawable/login_faggot">
<TextView
android:gravity="center_horizontal"
android:layout_above="#+id/plsLogin"
android:text="Welcome."
android:textSize="18sp"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginBottom="25dp"
android:textSize="16sp"
android:textColor="#color/grayBg"
android:gravity="center_horizontal"
android:id="#+id/plsLogin"
android:layout_above="#+id/editLogin"
android:text="Please Login."
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editLogin"
android:layout_alignBaseline="#+id/editLogin"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<TextView
android:background="#color/white"
android:layout_alignLeft="#+id/editPass"
android:layout_alignBaseline="#+id/editPass"
android:layout_marginStart="50dp"
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<EditText
android:paddingStart="20dp"
android:drawableStart="#drawable/ic_mail_white_24dp"
android:drawablePadding="15dp"
android:hint="#string/user_name"
android:layout_alignStart="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_above="#+id/editPass"
android:id="#+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:drawableStart="#drawable/ic_lock_white_24dp"
android:paddingStart="20dp"
android:drawablePadding="15dp"
android:hint="#string/password"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_above="#+id/linearLayout"
android:id="#+id/editPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginStart="15dp"
android:id="#+id/linearLayout"
android:layout_above="#+id/buttonLogin"
android:layout_alignEnd="#+id/buttonLogin"
android:layout_alignStart="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content">
<CheckBox
style="#style/Widget.AppCompat.CompoundButton.RadioButton"
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:paddingStart="15dp"
android:textColor="#color/white"/>
<TextView
android:visibility="invisible"
android:id="#+id/textView"
android:textColor="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="Forgot Password"/>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:background="#drawable/button_round_corner"
app:backgroundTint="#color/colorOrangeUsSite"
android:text="#string/login"
android:textColor="#color/white"/>
<FrameLayout
android:background="#color/black"
android:alpha="0.8"
android:visibility="gone"
android:id="#+id/layoutProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:theme="#style/ProgressBar"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>
Related
This issue is occuring randomly and I am an intermediate in developing native android applications. This issue ossurs 1% of user engagements within the app. Randomly I can view crash reports of this in firebase crashlytics as follows
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{my.artic.lotcalculatorglobal/my.artic.lotcalculatorglobal.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.widget.RelativeLayout
This is 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/alt_background"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<RelativeLayout
android:id="#+id/titleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/dropMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end">
<RelativeLayout
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="20dp"
android:background="#drawable/menu"
android:onClick="showPopup" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/calculatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/titleBar"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="80dp">
<androidx.core.widget.NestedScrollView
android:id="#+id/calScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonlayout"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/layout_background"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/fund_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="#string/fund"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/fund"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_edit_text"
android:hint="#string/input_the_fund_value"
android:inputType="numberDecimal" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/crypto_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="#string/choose_crypto"
android:textColor="#color/white"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="#drawable/bg_edit_text">
<Spinner
android:id="#+id/tab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:backgroundTint="#color/white"
android:gravity="center"
android:nestedScrollingEnabled="true"
android:spinnerMode="dropdown" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:background="#drawable/bg_edit_text" />
<Spinner
android:id="#+id/currencyType"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:backgroundTint="#color/white"
android:gravity="center"
android:nestedScrollingEnabled="true"
android:spinnerMode="dropdown"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="#string/service_charge"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/s_charge"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_edit_text"
android:hint="#string/input_the_service_charge_value"
android:inputType="numberDecimal" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp" />
<EditText
android:id="#+id/lockUpDeposit"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_edit_text"
android:hint="#string/input_the_currency_value"
android:inputType="numberDecimal"
android:paddingStart="20dp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="#string/range"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/range"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_edit_text"
android:hint="#string/input_the_range_value"
android:inputType="numberDecimal"
android:paddingStart="10dp"
android:textColorHint="#color/light_green"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginTop="5dp"
android:layout_toStartOf="#+id/seek_value"
android:orientation="vertical">
<SeekBar
android:id="#+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="-15dp"
android:max="15"
android:min="5"
android:progress="15" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="0.5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="1.5"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/seek_value"
android:layout_width="45dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:background="#drawable/bg_edit_text"
android:gravity="center"
android:text="1.5" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginBottom="5dp"
android:weightSum="2">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="10dp"
android:text="#string/lot" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:animateLayoutChanges="true"
android:orientation="horizontal">
<TextView
android:id="#+id/lot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_white"
android:padding="10dp"
android:text="0.0" />
<RelativeLayout
android:id="#+id/copy"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:background="#drawable/icon_copy"
android:onClick="onClick"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/s_charge" />
<TextView
android:id="#+id/charge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:animateLayoutChanges="true"
android:background="#drawable/bg_white"
android:text="0.0" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/profit_range"/>
<TextView
android:id="#+id/profit_range"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="#drawable/bg_white"
android:padding="10dp"
android:text="0.0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/gross_profit" />
<TextView
android:id="#+id/gross_profit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" 0.0" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<RelativeLayout
android:id="#+id/buttonlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:weightSum="2">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/calculate"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/bg_button_main"
android:onClick="onClick" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/clear"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#drawable/bg_button_main"
android:onClick="onClick" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/clearAll"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#drawable/bg_button_main"
android:onClick="onClick" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>`
I have a problem filling the entire screen in a reclycle view.
This is my xml code of the cardview and my view where the reclyclerview is:
CardView:
This is how it looks in the Ide Android studio:
Layout where the Reclycler view is:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="30"
android:textSize="30sp" />
<TextView
android:id="#+id/textIdPerson"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="30"
android:textSize="30sp" />
<TextView
android:id="#+id/textId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="30"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="4dp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
app:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/textAmount"
android:padding="8dp"
android:text="ID"
android:textSize="30sp"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/textIdPerson"
android:padding="8dp"
android:layout_weight="1"
android:text="UserId"
android:textSize="30sp"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/textId"
android:padding="8dp"
android:textSize="30sp"
android:layout_weight="1"
android:text="Amount"
android:gravity="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/recycler_view"
android:nestedScrollingEnabled="false"
tools:listitem="#layout/list_row_main"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="atras"
android:onClick="#{viewmodel::back}"
android:layout_weight="1"
android:layout_marginRight="4dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Siguiente"
android:onClick="#{viewmodel::next}"
android:layout_weight="1"/>
</LinearLayout>
Image:
enter image description here
But when I start the application on the device it looks like this
enter image description here
Your activity_main.xml(or any layout that hosts recyclerview) should look like this.
<androidx.appcompat.widget.LinearLayoutCompat 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:orientation="vertical"
>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
app:cardCornerRadius="5dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center_vertical|center"
android:orientation="horizontal">
<TextView
android:id="#+id/textAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="Amount"
android:textSize="30sp" />
<TextView
android:id="#+id/textIdPerson"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="UserID"
android:textSize="30sp" />
<TextView
android:id="#+id/textId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:text="Id"
android:textSize="30sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:layout_weight="2"
android:nestedScrollingEnabled="false"
tools:listitem="#layout/list_item" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/btnAtras"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:text="ATRAS"
/>
<Button
android:id="#+id/btnSignature"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:text="Signature" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
And list_item.xml layout should be something like below:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="60dp"
app:cardCornerRadius="5dp"
app:cardElevation="8dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
app:cardUseCompatPadding="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center"
android:gravity="center|center_vertical"
>
<TextView
android:gravity="center"
android:id="#+id/textAmount"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="match_parent"
android:padding="8dp"
android:text="Amount"
android:textSize="30sp" />
<TextView
android:gravity="center"
android:id="#+id/textIdPerson"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="match_parent"
android:padding="8dp"
android:text="UserId"
android:textSize="30sp" />
<TextView
android:gravity="center"
android:id="#+id/textId"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="match_parent"
android:padding="8dp"
android:text="Id"
android:textSize="30sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Check your adapter class, Layout you designed for adapter class should have width match parent and three different textviews with equal width to hold values.
Make sure the RecyclerView has layout_width also set to match_parent.
I need to pin the image while scrolling with the headed section and need to scroll other thing in the screen.
Here I need the header as fixed while scrolling and the half of the fill 2 image shown while scrolling.
Now the header actionsof on click are not working after addding nestedScrollView.
Also the nested view is overlapping with the above view while scrolling
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinator"
style="#style/CoordinatorLayout"
android:background="red"
tools:ignore="RtlHardcoded">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/layout_app_bar"
style="#style/Collapsing.AppBarLayout"
android:background="blue">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/layout_collapsing_toolbar"
style="#style/Collapsing.CollapsingToolbarLayout"
android:layout_height="427dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_x5"
android:background="green"
android:gravity="center"
android:id="#+id/header_view"
android:visibility="visible"
android:orientation="horizontal">
<ImageView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/black"
android:clickable="true"
android:contentDescription="#string/back"
android:src="#drawable/ic_arrow_left"/>
<TextView
android:id="#+id/header_my_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:textSize="18dp"
android:gravity="center"
android:textColor="#color/white"
android:scaleType="centerInside"
android:text="MY Home Feed"/>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical"
>
<TextView
android:id="#+id/label1"
android:layout_width="80dp"
android:layout_height="48dp"
android:gravity="center"
android:visibility="visible"
android:clickable="true"
android:textSize="18dp"
android:textColor="#707070"
android:text="label1"
/>
</RelativeLayout>
</LinearLayout>
<ImageView
android:id="#id/iv_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="50dp"
android:adjustViewBounds="true"
android:src="#drawable/image" />
<ImageView
android:id="#id/fill_1"
android:src="#drawable/fill_1"
android:scaleType="fitStart"
android:layout_marginTop="148dp"
android:layout_marginLeft="-20dp"
android:layout_marginRight="-20dp"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#id/fill_2"
android:src="#drawable/fill_2"
android:scaleType="fitCenter"
android:layout_marginTop="128dp"
android:layout_marginLeft="-20dp"
android:layout_marginRight="-20dp"
android:layout_marginBottom="-30dp"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Collapsing.Toolbar" />
<View
android:id="#+id/divider"
style="#style/Collapsing.Divider" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/nested_scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:layout_marginTop="500dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="27dp"
android:layout_marginTop="5dp"
android:layout_gravity="center"
>
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="#+id/recycler_view"
android:orientation="horizontal"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
<View style="#style/Divider.Horizontal.Gray"
android:layout_width="match_parent"
android:layout_marginTop="#dimen/spacing_x2"
android:layout_marginBottom="#dimen/spacing_x2"
android:layout_height="2dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:visibility="gone"
android:layout_marginRight="20dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="21sp"
android:layout_weight="1"
android:layout_gravity="left"
>
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="14sp"
android:layout_weight="0.1"
android:layout_gravity="right"
android:text="lanl">
</TextView>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/recycler_view"
android:visibility="gone"
android:orientation="vertical"
>
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="21sp"
android:layout_weight="1"
>
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:textSize="14sp"
android:layout_weight="0.1"
android:layout_gravity="right"
>
</TextView>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:id="#+id/recycler_view1"
android:orientation="horizontal"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
<View style="#style/Divider.Horizontal.Gray"
android:layout_width="match_parent"
android:layout_marginTop="#dimen/spacing_x2"
android:layout_marginBottom="#dimen/spacing_x2"
android:layout_height="2dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:layout_weight="1"
android:layout_gravity="left"
>
</TextView>
<ImageView
android:layout_width="30dp"
android:layout_height="27dp"
android:layout_weight="0.1"
android:layout_gravity="right"
>
</ImageView>
</LinearLayout>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#id/search"
android:layout_marginTop="15dp"
android:background="#color/dark_blue"
app:tabGravity="fill"
app:tabIndicatorColor="#color/blue_light"
app:tabIndicatorHeight="5dp"
app:tabMode="scrollable" />
<com.finaonation.utility.NonScrollableViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_margin="20dp"
android:orientation="horizontal"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:layout_weight="1"
android:layout_gravity="left"
android:textSize="16sp"
</TextView>
<ImageView
android:layout_width="30dp"
android:layout_height="27dp"
android:layout_weight="0.1"
android:layout_gravity="right"
>
</ImageView>
</LinearLayout>
<View style="#style/Divider.Horizontal.Gray"
android:layout_width="match_parent"
android:layout_marginTop="#dimen/spacing_x2"
android:layout_marginBottom="#dimen/spacing_x2"
android:layout_height="2dp"
android:id="#+id/divider"
android:visibility="visible"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_margin="20dp"
android:id="#+id/recycler_view_m"
android:orientation="horizontal"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<android.support.design.widget.CoordinatorLayout
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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- HEADER -->
<RelativeLayout
...
app:layout_collapseMode="parallax">
.....
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
<!-- IF YOU WANT TO KEEP "Choose Item" always on top of the RecyclerView, put this TextView here
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="choose item" />
-->
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
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"/>
i'm trying to make (try again) button in center this button is invisible , i already tried to put : android:layout_gravity="center"
but doesn't work any suggestions for resolve this problems
This what he give me :
My XML file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#ffff"
android:id="#+id/activity_viewsol">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:theme="#style/ThemeOverlay.AppCompat.Light"
android:fitsSystemWindows="true"
app:layout_collapseMode="pin"
android:elevation="5dp"
app:navigationIcon="#drawable/ic_back"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="48sp"
android:textStyle="bold"
android:text="Solution"
android:id="#+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:id="#+id/scrollview"
android:stackFromBottom="true"
android:scrollbarSize="10dp"
android:scrollbarThumbVertical="#drawable/scrollbar"
android:transcriptMode="alwaysScroll">
<LinearLayout
android:id="#+id/All_Layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="6dp"
android:padding="15dp">
<TextView
android:typeface="normal"
android:layout_gravity="center"
android:id="#+id/prob"
android:textStyle="bold"
android:textColor="#383838"
android:gravity="center"
android:textSize="45sp"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="20dp">
<View
android:layout_height="1dp"
android:layout_width="500dp"
android:background="#000"
android:layout_gravity="center"/>
<TextView
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="O"
android:textSize="40sp"
android:textColor="#color/colorAccent"
android:textStyle="bold"
android:layout_gravity="center"/>
<View
android:layout_height="1dp"
android:layout_width="500dp"
android:background="#000"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="35sp"
android:textStyle="normal"
android:textColor="#383838"
android:id="#+id/sol"
android:typeface="normal"
android:layout_marginBottom="20dp"/>
<View
android:id="#+id/LineHorizontalTwo"
android:layout_height="1dp"
android:layout_width="1000dp"
android:background="#000"
android:layout_gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_margin="20dp"
android:layout_gravity="start|center"
android:id="#+id/Like"
android:src="#mipmap/ic_like"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_margin="20dp"
android:layout_gravity="end|center"
android:id="#+id/sharesol"
android:src="#mipmap/ic_action_share"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#mipmap/retry"
android:drawablePadding="10dp"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:id="#+id/retry"
android:onClick="onClickRetry"
android:background="#null"
android:padding="6dp"
android:textSize="35sp"
android:text="TRY AGAIN"
android:textColor="#000" />
</LinearLayout>
You can do it simply doing by enclosing your error button inside the Relative Layout as following steps:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="#+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:drawablePadding="10dp"
android:drawableTop="#drawable/ic_android"
android:gravity="center"
android:padding="6dp"
android:text="TRY AGAIN"
android:textColor="#000"
android:textSize="35sp"
android:visibility="visible" />
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
also you need a RelativeLayout for parent of this tag
Make the parent layout as RelativeLayout and put everything inside RelativeLayout except the button.
use
<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">
<!--Put your other codes here-->
<!--everything can be within LinerarLayout-->
<Button
android:id="#+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#null"
android:drawablePadding="10dp"
android:drawableTop="#mipmap/retry"
android:onClick="onClickRetry"
android:padding="6dp"
android:text="TRY AGAIN"
android:textColor="#000"
android:textSize="35sp"
android:visibility="gone" />
</RelativeLayout>
as your button code