Placing an ImageView above Buttons in center - android

I'm trying to get the following output:
So far i tried my code is this:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" >
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:padding="20dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="0dp" />
<Button
android:id="#+id/buttonChoose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Choose" />
<Button
android:id="#+id/buttonUpload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Upload" />
</LinearLayout>
I'm new to android sorry for this silly question.Explain me in details the problem if possible with appropiate solution.

Unlike all of the other answers, I want to explain to you what is the best layout you should use.For better responsive layout consider using constraint layout - very easy to use and comfortable. In addition when you are using LinearLayout with android:layout_weight it kind of makes your layout slower - the display layout engine needs more time to display your layout than constraintLayout.Here is an example using constraint layout:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="324dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:src="#drawable/common_google_signin_btn_icon_dark"
app:layout_constraintBottom_toTopOf="#+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="#+id/button2"
app:layout_constraintEnd_toStartOf="#+id/guideline2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/button2" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/guideline2"
app:layout_constraintTop_toBottomOf="#+id/imageView" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>

Replace your code with 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
tools:context="com.cash.nikito.Contact">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<!-- add src attribute here -->
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:orientation="horizontal"
android:padding="20dp">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1" />
<Button
android:id="#+id/buttonUpload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Upload" />
</LinearLayout>
</RelativeLayout>

many solution you have and one of them is :
set orientation = "vertical" for
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:padding="20dp">
and after add another LinearLayout with orientation = "Horizental" and inside that insert two button .

try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#+id/toolbar">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<ImageView
android:layout_width="wrap_content"
android:id="#+id/ivBack"
android:src="#drawable/ic_launcher_background"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:src="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp"
android:layout_height="wrap_content">
<Button
android:layout_width="0dp"
android:id="#+id/bChoose"
android:layout_weight="1"
android:layout_height="wrap_content" />
<Button
android:layout_width="0dp"
android:id="#+id/bUpload"
android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>

Related

How to disable or stop coordinate layout scroll

I'm facing one issue.
I have a coordinate layout and inside I have the toolbar and all that.
I have also one frame layout inside it and in-frame layout I have three fragments.
One chat fragment is there, in that I have one recycler view.
When moving to that tab I scroll the layout with AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED.
But when I scroll recycler view, coordinate layout also scrolls.
I want the coordinate layout scroll only the first time and want to diable when recycler view scrolls.
Here is my XML file.
<?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:id="#+id/co_ordinate_layout"
android:layout_height="match_parent"
android:background="#color/offwhite">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/offwhite"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
tools:ignore="ExtraText">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapseBar"
android:layout_width="match_parent"
android:layout_height="200dp"
app:expandedTitleMarginBottom="94dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#null"
android:backgroundTint="#color/white"
android:visibility="visible"
app:layout_collapseMode="pin"
app:navigationIcon="#drawable/ic_cancel" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<TextView
android:id="#+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_7sdp"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/_7sdp"
android:text="Mimi51"
android:textColor="#color/secondary_text"
android:textSize="#dimen/_20sdp"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/llProfile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp"
android:text="#string/profile"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<View
android:id="#+id/viewProfile"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
<LinearLayout
android:id="#+id/llPlayList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp"
android:text="#string/playlist"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<View
android:id="#+id/viewPlayList"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
<LinearLayout
android:id="#+id/llChat"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp">
<TextView
android:id="#+id/tvChat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:text="Chat"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<TextView
android:id="#+id/tvChatConut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:background="#drawable/stock_chat_count"
android:orientation="vertical"
android:paddingStart="#dimen/_10sdp"
android:paddingTop="#dimen/_2sdp"
android:paddingEnd="#dimen/_10sdp"
android:paddingBottom="#dimen/_2sdp"
android:text="1"
android:textAllCaps="true"
android:textColor="#color/theme"
android:textSize="#dimen/small_textsize" />
</LinearLayout>
<View
android:id="#+id/viewChat"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/view_header"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/gray_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cl_header" />
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgProfile"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:elevation="8dp"
android:padding="3dp"
android:src="#color/theme"
app:layout_anchorGravity="top|center_horizontal"
app:layout_scrollFlags="scroll" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

How do i place image in android toolbar?

how do I design profile picture like in this image in android? I tried placing it in the toolbar it won't show half below the toolbar.
Here is a look at the code I am trying. I am using a linear layout at top and then again a linear layout for holding logo and text and the image is at the bottom in root linear layout. Despite setting margin-top it still there and not moving to location:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:menu="#menu/action_menu"
android:background="#color/colorPink1"
android:elevation="0dp"
android:layout_margin="0dp"
app:collapseIcon="#drawable/logo_mini"
android:padding="0dp"
android:layout_height="wrap_content" android:minHeight="0dp">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top"
android:orientation="vertical" android:gravity="end" android:dividerPadding="100dp">
<LinearLayout
android:orientation="vertical"
android:id="#+id/main_layout"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:padding="5dp"
android:paddingLeft="50dp"
android:gravity="center">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/center_icon"
android:layout_gravity="center"
android:src="#drawable/logo_mini"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginTop="5dp"
/>
</LinearLayout>
<ImageView
android:layout_marginTop="5dp"
android:id="#+id/bar"
android:src="#drawable/bar"
android:background="#android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Hi ,"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/emp_name" android:textSize="30sp"/>
<TextView
android:text="Wellcome back,"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/textView5"/>
<TextView android:layout_width="match_parent" android:visibility="gone" android:layout_height="wrap_content"
android:text="here ae you assigned sites"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_gravity="bottom|end"
android:elevation="10dp"
android:src="#drawable/user_photo"
android:layout_alignBottom="#+id/center_icon"
android:layout_width="72dp"
android:layout_height="72dp"
android:gravity='center'
android:layout_marginTop="-50dp"
/>
</android.support.v7.widget.Toolbar>
you should use CoordinatorLayout and layout_anchor ,layout_anchorGravity attributes for the ImageView to locate the image on the edge of the toolbar
<android.support.design.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.support.v7.widget.Toolbar
android:id="#+id/toolbar"
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"
android:layout_margin="0dp"
android:background="#color/colorAccent"
android:elevation="0dp"
android:minHeight="0dp"
android:padding="0dp"
app:collapseIcon="#drawable/logo_mini">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:dividerPadding="100dp"
android:gravity="end"
android:orientation="vertical">
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp"
android:paddingLeft="50dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/center_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_weight="0"
android:src="#drawable/logo_mini" />
</LinearLayout>
<ImageView
android:id="#+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/white"
android:src="#mipmap/mic" />
<TextView
android:id="#+id/emp_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hi ,"
android:textSize="30sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Wellcome back,"
android:visibility="gone" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="here ae you assigned sites"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/icon"
android:layout_width="#dimen/dim150"
android:layout_height="#dimen/dim150"
android:layout_below="#+id/home_txt"
android:layout_marginTop="#dimen/dim20"
android:src="#drawable/user_photo"
app:layout_anchor="#id/toolbar"
app:layout_anchorGravity="bottom|center_horizontal" />
</android.support.design.widget.CoordinatorLayout>
you can change your layout like this,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar 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"
android:layout_margin="0dp"
android:background="#color/colorAccent"
android:elevation="0dp"
android:minHeight="0dp"
android:padding="0dp"
app:collapseIcon="#drawable/logo_mini">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:dividerPadding="100dp"
android:gravity="end"
android:orientation="vertical">
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp"
android:paddingLeft="50dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/center_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:layout_weight="0"
android:src="#drawable/logo_mini" />
</LinearLayout>
<ImageView
android:id="#+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/white"
android:src="#mipmap/mic" />
<TextView
android:id="#+id/emp_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hi ,"
android:textSize="30sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Wellcome back,"
android:visibility="gone" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="here ae you assigned sites"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentRight="true"
android:layout_marginTop="80dp"
android:elevation="10dp"
android:gravity='center'
android:src="#drawable/user_photo" />
</RelativeLayout>
Try to use Constraint Layout to make responsive UI
<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=".StartActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#color/colorPrimary">
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginEnd="24dp"
android:background="#color/colorAccent"
android:src="#drawable/ic_launcher_foreground"
app:layout_constraintBottom_toBottomOf="#+id/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" /></android.support.constraint.ConstraintLayout>

Scrolling issue when using CoordinatorLayout with AppBarLayout

I have AppBarLayout inside CoordinatorLayout while scrolling from AppBarLayout area from top to bottom then some time suddenly scrolls up.
here is the result1 result2
Layout :
<?xml version="1.0" encoding="utf-8"?>
<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:background="#color/white"
android:orientation="vertical"
app:elevation="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/layout_header_title_list_item_listing" />
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/imgThumbDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<cn.jzvd.JZVideoPlayerStandard
android:id="#+id/videoplayerDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.videosgifsimages.smallbang.SmallBangView
android:id="#+id/like_heart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:clickable="false"
android:visibility="invisible"
app:circle_end_color="#00000000"
app:circle_start_color="#00000000"
app:dots_primary_color="#c60d2c"
app:dots_secondary_color="#e9cf0b"
app:layout_constraintBottom_toBottomOf="#+id/videoplayerDetails"
app:layout_constraintEnd_toEndOf="#+id/videoplayerDetails"
app:layout_constraintStart_toStartOf="#+id/videoplayerDetails"
app:layout_constraintTop_toTopOf="#+id/videoplayerDetails">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_like_animate" />
</com.videosgifsimages.smallbang.SmallBangView>
</android.support.constraint.ConstraintLayout>
<include
layout="#layout/layout_bottom_list_item_listing"
android:layout_width="match_parent"
android:layout_height="54dp"
app:layout_scrollFlags="scroll" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#f2f2f2"
app:layout_scrollFlags="scroll">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ad"
android:textColor="#565656"
android:textSize="12sp"
android:textStyle="normal" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:background="#ecf0f1"
android:orientation="horizontal"
android:padding="10dp">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/rounded_edittext_post_comment"
android:hint="Comment"
android:inputType="textPersonName"
android:paddingEnd="15dp"
android:paddingStart="15dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginStart="17dp"
android:background="#drawable/circle_background_post_comment_btn"
android:scaleType="centerInside"
android:src="#drawable/ic_post_comment" />
</LinearLayout>
<View
android:id="#+id/viewDimBgForBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:visibility="gone" />
<include layout="#layout/bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>

White space under expandable List View, how to make it disappear?

I tried to enlarge the ListView to make it fill the screen , but no way.
here is the layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_collapseParallaxMultiplier="0.0">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:orientation="horizontal">
<TextView
android:id="#+id/textViewweight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:textAlignment="textEnd"
android:textAppearance="#android:style/TextAppearance.Material.Small"
app:layout_constraintHorizontal_bias="0.473"
app:layout_constraintLeft_toRightOf="#+id/textViewdrug"
app:layout_constraintRight_toLeftOf="#+id/textViewage"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/textViewage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:textAlignment="center"
android:textAppearance="#android:style/TextAppearance.Material.Small"
app:layout_constraintHorizontal_bias="0.919"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/textViewdrug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:textAlignment="textStart"
android:textAppearance="#android:style/TextAppearance.Material.Small"
app:layout_constraintHorizontal_bias="0.095"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</LinearLayout>
<ExpandableListView
android:id="#+id/idListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/graymillidos"
/>
</LinearLayout>
is there any mistakes in my code ?
and here is the result :

LinearLayout unexpected margin at the top

I am using a BottomNavigationBar and LinearLayout as the first layout tab but this unexpected margin at the top is showing i already changed my dimens to 0dp but nothing changes.
This is my Main fragment
<LinearLayout 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/controlView"
android:layout_width="match_parent"
android:layout_height="16dp" />
<FrameLayout
android:id="#+id/content_frag"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/colorPrimaryDark"
app:menu="#menu/navigation" />
</LinearLayout>
Actually there are two layouts having the same margin problem and this is one of them
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/grey_300">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#drawable/gcover"
android:id="#+id/relativeLayout">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profPhoto"
android:clickable="true"
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="20dp"
android:src="#drawable/default_prof"
android:scaleType="centerCrop"
app:civ_border_color="#color/trans"
app:civ_border_width="2dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<android.support.v7.widget.AppCompatButton
android:id="#+id/prof_invite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="2dp"
android:background="#color/green_300"
android:drawableLeft="#drawable/icon1"
android:padding="12dp"
android:text="invite friends" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/prof_conf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="2dp"
android:background="#color/ball_D"
android:drawableLeft="#drawable/icon2"
android:padding="12dp"
android:text="settings" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/prof_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="2dp"
android:background="#color/colorPrimaryDark"
android:drawableLeft="#drawable/icon"
android:padding="12dp"
android:text="log out" />
</LinearLayout>
<View
android:id="#+id/controlView"
android:layout_width="match_parent"
android:layout_height="16dp" />
This is your problem.
Remove this and it will be fine.

Categories

Resources