I have three TextViews which I want to place inside a Linear Layout. When I do this, the TextFields disappear on the screen. They reappear if I take them out of the Linear Layout, and put them into the Relative Layout, for example.
Below is the code from my Linear Layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ViewSingleClub">
<Button
android:id="#+id/btnViewAllClubs"
android:layout_width="177dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Clubs"
android:textAllCaps="false"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="444dp"
android:layout_marginTop="68dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#drawable/gradientsbackground"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="#+id/imgView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
<TextView
android:id="#+id/txtClubName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Club Name"
android:textColor="#fff"
android:textSize="36sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
<TextView
android:id="#+id/txtClubDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:text="Club Description"
android:textColor="#color/common_google_signin_btn_text_dark_focused"
android:textSize="30sp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="117dp" />
<TextView
android:id="#+id/txtClubEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="#color/common_google_signin_btn_text_dark_focused"
android:textSize="24sp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="157dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
I don't understand why this is happening. Could anyone help me out?
In your LinearLayout, the layout height is restricted to 350dp, and you have an ImageView with match parent in the layout. Try to make the LinearLayout height to wrap_content, or set a fixed height for the ImageView.
...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#drawable/bg_gradient"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="#+id/imgView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
...
OR
...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_gradient"
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="#+id/imgView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="68dp" />
...
Related
I have a view with a title bar above (RelativeLayout) and below a LinearLayout with weightSum.
I used the weightSum because I wanted to distribute the three elements (ImageView, TextView, Button ) 100% contained in the page.
Everything works fine, but when I go to write something from the textview the keyboard appears and the bar disappears from the view because it drags over.
I tried various systems to try to insert the scoolview and keep the bar fixed at the top.
I used both the scrollview and the NestedScrollView and I also changed the bar created with the RelativeLayout to a toolbar.
but the content of the LinearLayout with the weightSum stretches a lot.
do you have any suggestion for me?
thank you
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/fond"
android:fillViewport="true"
tools:context=".client.FicheClient">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center|top"
android:gravity="center|top">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/surface_l"
android:orientation="horizontal"
android:paddingLeft="56dp"
android:paddingRight="56dp">
<TextView
android:id="#+id/txtNomFichier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:ellipsize="end"
android:fontFamily="#font/inter_bold_700t"
android:gravity="center_horizontal"
android:maxLines="1"
android:text="#string/label_document"
android:textColor="#color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="backList"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingEnd="16dp"
android:paddingBottom="12dp">
<ImageView
android:id="#+id/btn_Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/icone_arrow_left_blanc" />
</LinearLayout>
<Button
android:id="#+id/btn_share"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:background="#drawable/fond_partage"
android:fontFamily="#font/inter_regular_400t"
android:onClick="launchPartage"
android:text=""
android:textColor="#color/blanc"
android:visibility="invisible" />
<ProgressBar
android:id="#+id/progressBarTop"
style="?android:attr/progressBarStyle"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:theme="#style/colorProgressBarTop" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="77"
android:background="#drawable/radius_gris"
android:orientation="vertical">
<ImageView
android:layout_gravity="center_horizontal|center_vertical"
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.barteksc.pdfviewer.PDFView
android:layout_gravity="center_horizontal|center_vertical"
android:id="#+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_weight="11"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:padding="12sp"
android:background="#drawable/radius_blanc"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/txtLibelleNomFichier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/inter_regular_400t"
android:gravity="left|center_vertical"
android:text="#string/label_file_name_obligatoire"
android:textColor="#color/surface_h"
android:textSize="12sp" />
<EditText
android:id="#+id/txtNom"
android:layout_width="match_parent"
android:layout_height="18dp"
android:background="#drawable/textedit_blanc_rounded_corners"
android:textColor="#color/surface_k"
android:ellipsize="end"
android:textSize="12sp"
android:fontFamily="#font/inter_semi_bold_600t"
android:gravity="left|center_vertical"
android:inputType="text"
android:maxLines="1"
android:layout_marginTop="2dp"
android:scrollHorizontally="true" />
</LinearLayout>
<LinearLayout
android:background="#color/blanc"
android:layout_weight="12"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="#+id/btn_upload"
android:layout_width="match_parent"
android:layout_height="39dp"
android:layout_columnWeight="1"
android:layout_margin="16dp"
android:textAllCaps="false"
android:background="#drawable/radius_primary_5"
android:text="#string/btn_validate"
android:textColor="#color/blanc" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
How do I create a layout with two buttons that can fill half of the layout from left and the second button on the right with also a view below as a border?
My layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
tools:context=".Login">
<RelativeLayout
android:gravity="center_horizontal"
android:layout_marginTop="70dp"
android:layout_marginBottom="70dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_45sdp"
android:background="#color/white"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_chat"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:text="LOGIN" />
<Button
android:id="#+id/btn_cart"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white"
android:textColor="#color/lightDark"
android:textStyle="bold"
android:text="REGISTER" />
</RelativeLayout>
<View
android:id="#+id/active_border"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
<View
android:id="#+id/inactive_border"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="#color/lightDark"
android:layout_width="wrap_content"
android:layout_height="1dp"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
You could use the ConstraintLayout as the parent and set app:layout_constraintWidth_percent="0.5" in the child to make sure it takes the half of the width. Also use the constrain to make sure the buttons are on top of the border view.
For example the following code uses ConstraintLayout to achieve something similar:
<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="wrap_content">
<Button
android:id="#+id/btn1"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="#+id/borderView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5" />
<Button
android:id="#+id/btn2"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/borderView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5" />
<View
android:id="#+id/borderView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/black"
app:layout_constraintBottom_toBottomOf="parent" />
In the below layout i have a text view named as scanning device.In that am displaying a device name But my device list was displaying above the screen .
can any one please help me how to scroll view should be inside the device list.while scrolling the screen it was displaying the list of the devices but it is displaying above the screen.
want to display inside a screen.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:text="#string/back"
android:textAllCaps="true"
android:textColor="#color/white"
android:visibility="invisible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:padding="10dp"
android:textStyle="bold"
android:text="#string/lamp_list"
android:textAllCaps="true"
android:textColor="#color/white" />
<TextView
android:id="#+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableRight="#drawable/refresh"
android:gravity="right"
android:padding="10dp"
android:textAllCaps="true"
android:textColor="#color/white" />
<ProgressBar
android:id="#+id/scanningProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:background="#drawable/baground"
android:orientation="vertical">
<TextView
android:id="#+id/scan_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="18dp"
android:gravity="center"
android:text="#string/start_discovery"
android:textColor="#color/white"
android:visibility="gone"
tools:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:id="#+id/deviceListView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
In the below layout connect textview was coming out of the layout.
device_item.xml:
<?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:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="6dp"
android:src="#drawable/lamp" />
<TextView
android:id="#+id/deviceName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:textColor="#color/white"
android:textSize="17sp"
tools:text="Solar Enviro SSL 2016" />
<TextView
android:id="#+id/connect"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:background="#drawable/rounded_red_view"
android:text="#string/connect"
android:paddingBottom="1dp"
android:paddingTop=".2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textColor="#color/white"
android:textSize="17sp" />
</LinearLayout>
change this things..
used both wrap_content. i hope you also remove default action bar.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<TextView
android:id="#+id/scan_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="18dp"
android:gravity="center"
android:visibility="gone"
tools:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:id="#+id/deviceListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Instead of CoordinatorLayout use linear layout.
if u r a beginner start coding with linear layout. It is easy to understand.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
I want to build the following screen which contains app logo, success/failure icon image, information message and ok button.
Here this the code. I am using linear layout to achieve this.
<LinearLayout
android:id="#+id/statusLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#android:color/white"
android:weightSum="2"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="#+id/statusTopRelativeLayout"
android:background="#android:color/holo_blue_bright"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1">
<ImageView
android:id="#+id/client_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/no_image_description"
android:src="#drawable/client_logo"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/statusBottomRelativeLayout"
android:background="#android:color/holo_blue_light"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="#string/statusText"
android:textSize="50sp"/>
<Button
android:id="#+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/statusText"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:clickable="true"
android:focusable="true"
android:onClick="goToHomeScreen"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#string/ok"
android:textColor="#ffffff"
android:textSize="40sp"/>
</RelativeLayout>
How to place success/failure icon image on top of the two layouts?
You can use constraint to make it easy
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.Guideline
android:id="#+id/center"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#id/center"
android:background="#ffffff"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="#id/center"
app:layout_constraintBottom_toBottomOf="parent"
android:background="#00ffff"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#ff8801"
app:layout_constraintTop_toTopOf="#id/center"
app:layout_constraintBottom_toBottomOf="#id/center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>
Output:
Try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/nilu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:paddingBottom="30dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
</LinearLayout>
<LinearLayout
android:id="#+id/nilu2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/nilu"
android:layout_weight="1"
android:background="#color/colorAccent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/ic_launcher_round" />
</RelativeLayout>
</RelativeLayout>
OUTPUT
Parent RelativeLayout
add child LinearLayout as fillParent and assign weightsum 2. add two
layouts with 1 weight each. (add individual implementation for each
layout according to your requirements.)
add second child in relative
layout as imageview/button for that good sign and set it center in
parent.
This will fix your problem
I have a ScrollView in my app and inside it I have created a Linear Layout which contains various elements but the problem is this my buttons on bottom are not displayed properly. They are cut off at bottom. I have used padding and margin but nothing has been happened. Below is my layout
<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/light_gray">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/dp20"
android:layout_marginRight="#dimen/dp20"
android:layout_marginTop="#dimen/dp30"
android:orientation="vertical">
<ImageView
android:id="#+id/imgArticleImage"
android:layout_width="match_parent"
android:layout_height="#dimen/dp140"
android:layout_marginBottom="#dimen/dp15"
android:background="#android:color/white"
android:scaleType="fitXY"
android:src="#drawable/banner" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_grey_border_white_bg">
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp5"
android:text="#string/title"
android:textColor="#android:color/black" />
<android.support.design.widget.TextInputLayout
android:id="#+id/ettxtLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtTitle"
android:padding="#dimen/dp5"
app:counterEnabled="true"
app:counterMaxLength="100"
app:counterTextAppearance="#style/TextLimitStyle">
<android.support.design.widget.TextInputEditText
android:id="#+id/etTitile"
android:layout_width="match_parent"
android:layout_height="#dimen/dp80"
android:background="#android:color/transparent"
android:gravity="top"
android:maxLength="100" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp20"
android:background="#drawable/bg_grey_border_white_bg">
<TextView
android:id="#+id/txtTitleDes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp5"
android:text="#string/start_writing"
android:textColor="#android:color/black" />
<android.support.design.widget.TextInputLayout
android:id="#+id/ettxtLayoutDes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/txtTitleDes"
android:padding="#dimen/dp5"
app:counterEnabled="true"
app:counterMaxLength="1200"
app:counterTextAppearance="#style/TextLimitStyle">
<android.support.design.widget.TextInputEditText
android:id="#+id/etDescription"
android:layout_width="match_parent"
android:layout_height="#dimen/dp140"
android:background="#android:color/transparent"
android:gravity="top"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/layNew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp10"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="#+id/btnSave_draft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginRight="#dimen/dp20"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/save_draft"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnPublish_article"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/publish_your_article"
android:textColor="#android:color/white"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/layUpdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp10"
android:gravity="center"
android:orientation="horizontal"
>
<Button
android:id="#+id/btnDiscardChanges"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginRight="#dimen/dp20"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/discard_changes"
android:textColor="#android:color/white" />
<Button
android:id="#+id/btnSaveChanges"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="#android:color/holo_blue_light"
android:paddingLeft="#dimen/dp10"
android:paddingRight="#dimen/dp10"
android:text="#string/save_changes"
android:textColor="#android:color/white"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<ProgressBar
android:id="#+id/pBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
`
Can anyone suggest me what I have missed?
Wrap up another LinearLayout under the ScrollView and give
paddingBottom to the Second child (the second LinearLayout)
so add this to the added linearLayout :-
android:paddingBottom="20dp"
Correct order for padding :-
ScrollView
||
LinearLayout X- X -- > padding Bottom wont be applied
||
LinearLayout with paddingBottom -- > is applicable
Note :- paddingBottom and marginBottom cannot be applied to the immediate child of the ScrollView.
Remove
android:paddingBottom="#dimen/dp10"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
Just add android:paddingBottom="#dimen/dp30" into your LinearLayout:
<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/light_gray">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/dp10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/dp20"
android:layout_marginRight="#dimen/dp20"
android:layout_marginTop="#dimen/dp30"
android:orientation="vertical"
android:paddingBottom="#dimen/dp30">