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.
Related
I Have Two Fragment class for my project, On my first FragmentA, I have added a FrameLayout to the FragmentA xml file,named as filter_pop_up_frame_lyt_container. so on a button click from from FragmentA, Im adding a new FragmentB to the framelayout of FragmentA. so my intention was to see the framelayout height to be match parent. When my recyclerView items in FragmentA is loaded, the height of the Frame Layout taking only the height of the FragmentB . How can we make the framelayout matchparent.
Tried with this solution :FrameLayout height not matching parent , but not working for me.
sampleCode for my FragmentA xml File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tastry_btn_txt"
tools:openDrawer="start">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.agrawalsuneet.dotsloader.loaders.CircularDotsLoader
android:id="#+id/circle_dot_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:elevation="100dp"
android:foregroundGravity="center"
android:visibility="visible"
app:loader_bigCircleRadius="25dp"
app:loader_circleRadius="5dp"
app:loader_defaultColor="#color/blue_dark"
app:loader_firstShadowColor="#color/lit_grey6"
app:loader_secondShadowColor="#color/lit_grey4"
app:loader_selectedColor="#color/lit_grey3"
app:loader_showRunningShadow="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The ActionBar displayed at the top -->
<androidx.appcompat.widget.Toolbar xmlns:app="http://schemas.android.com/tools"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/palate_survey_bg"
app:ignore="NamespaceTypo"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.SearchView
android:id="#+id/Advance_search"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginEnd="50dp"
android:background="#drawable/filter_search_bar_bg_lyt"
app:iconifiedByDefault="false"
app:queryHint="Search">
</androidx.appcompat.widget.SearchView>
<View
android:id="#+id/filter_loc_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="20dp"
android:layout_marginTop="40dp"
android:background="#99a3bc" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:id="#+id/search_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:background="#66100202"
android:clickable="true"
android:orientation="vertical"
android:translationZ="15dp"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:fontFamily="sans-serif-medium"
android:text="Popular Searches"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="normal">
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_advance_search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tastry_btn_txt"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/filter_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:src="#drawable/filter">
</ImageView>
<TextView
android:id="#+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:fontFamily="sans-serif-medium"
android:text="Filter By"
android:textColor="#color/white"
android:textSize="22sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:id="#+id/filter_container_lyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:layout_alignParentTop="true"
android:layout_marginTop="2dp"
android:background="#495471"
android:gravity="center_vertical"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_filter_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget" />
</LinearLayout>
<RelativeLayout
android:id="#+id/wine_complete_lyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:layout_marginStart="3dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_red_wine_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" />
</RelativeLayout>
<FrameLayout
android:id="#+id/filter_pop_up_frame_lyt_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:background="#color/orange"
android:elevation="50dp"
android:translationZ="30dp" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/palate_survey_bg"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header"
app:itemIconSize="20dp"
app:itemIconTint="#color/white"
app:itemTextColor="#color/white"
app:menu="#menu/drawermenu" />
</androidx.drawerlayout.widget.DrawerLayout>
sampleCode for FragmentB layout:
<?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"
android:id="#+id/linear_layout_root_price_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66FF0000"
android:orientation="vertical">
<!-- android:background="#drawable/filter_bg_round_corner"-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/filter_bg_round_corner"
android:orientation="vertical">
<LinearLayout
android:id="#+id/progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="vertical">
<com.google.android.material.slider.RangeSlider
android:id="#+id/filter_price_ranger_Slider"
style="#style/Theme.TastrySampleApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/progress_layout_bg"
android:stepSize="1"
android:theme="#style/Theme.TastrySampleApp"
android:valueFrom="0.0"
android:valueTo="100.0"
app:labelBehavior="gone"
app:thumbColor="#01b0c3"
app:tickVisible="false"
app:values="#array/initial_slider_values" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/onStartTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:ellipsize="end"
android:maxLines="1"
android:text="$0"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
<TextView
android:id="#+id/onStopTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="end"
android:maxLines="1"
android:text="$100+"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_marginTop="20dp"
android:background="#99a3bc">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:gravity="right"
android:orientation="horizontal"
android:padding="14dp">
<TextView
android:id="#+id/filter_price_wine_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="1234"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<TextView
android:id="#+id/filter_price_wine_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="0"
android:ellipsize="end"
android:maxLines="1"
android:text="Wines"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<View
android:layout_width="0dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_weight="1" />
<LinearLayout
android:id="#+id/filter_price_root_clear_lyt"
android:layout_width="110dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_toLeftOf="#+id/filter_price_Apply"
android:background="#drawable/filter_clear_bg"
android:gravity="center"
android:visibility="gone">
<ImageView
android:id="#+id/close_filter_price"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:src="#drawable/close_white">
</ImageView>
<TextView
android:id="#+id/clear_price_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/close_filter_price"
android:text="Clear All"
android:textColor="#f2faff"
android:textStyle="bold">
</TextView>
<TextView
android:id="#+id/price_clear_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/clear_price_filter"
android:textColor="#f2faff"
android:textStyle="bold">
</TextView>
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/filter_price_Apply"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:background="#drawable/filter_apply_bg"
android:gravity="center"
android:text="Apply"
android:textAllCaps="false"
android:textColor="#f2faff"
android:textSize="12sp"
android:visibility="gone">
</com.google.android.material.button.MaterialButton>
</LinearLayout>
</LinearLayout>
</LinearLayout>
When I removed the scrollview from the layout , the height of the frame layout was set to match parent. Worked perfectly.
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>
I found that my last item in RecyclerView can't show when RecyclerView inside GridLayot.
I try to remove GridLayot and just use RecyclerView, and it can show all items, but I can't use these solution because I need to show my AppBarLayout too. So I need to use GridLayot to make AppBarLayout and RecyclerView be a group, and SwipeRefreshLayout can use.
How can I fix that, thank you!
<?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:background="#color/colorWhite">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/activity_cost_diamond_history_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorComtGray">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="1"
android:rowCount="2">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_row="0">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/activity_cost_diamond_history_user_cost_diamond_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_point" />
<TextView
android:id="#+id/activity_cost_diamond_history_user_cost_diamond_text"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="17sp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/activity_cost_diamond_history_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</GridLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
Make recyclerview row 1
<androidx.recyclerview.widget.RecyclerView
android:layout_row="1"
android:id="#+id/activity_cost_diamond_history_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
or Use your layout like this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/activity_cost_diamond_history_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="1"
android:rowCount="1">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_row="0">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/activity_cost_diamond_history_user_cost_diamond_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_back" />
<TextView
android:id="#+id/activity_cost_diamond_history_user_cost_diamond_text"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:gravity="center"
android:textColor="#color/background"
android:textSize="17sp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
</GridLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/activity_cost_diamond_history_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
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>
I am using below xml code with adjustresize option with activity to resize it but my recyclerview disappear after resize.
<?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:id="#+id/content_add_document"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.labs108.teddy.activities.AddListActivity"
tools:showIn="#layout/activity_add_list">
<android.support.v7.widget.CardView
android:id="#+id/card_layout"
android:layout_width="match_parent"
android:layout_height="320dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/title"
android:layout_marginLeft="16dp"
android:hint="Title"
android:background="#null"
android:layout_width="match_parent"
android:layout_height="52dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#drawable/img_divider" />
<ScrollView
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_marginBottom="40dp"
android:layout_height="262dp">
<com.github.irshulx.Editor
android:id="#+id/description"
android:gravity="top"
app:render_type="Editor"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="100dp"
app:placeholder="Start writing here..."
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#drawable/img_divider" />
</LinearLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:id="#+id/documentlayout"
android:layout_below="#+id/card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/document_image"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<RelativeLayout
android:id="#+id/rl_add_info_bottom"
android:layout_width="328dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:layout_below="#+id/document_image"
android:background="#drawable/button_white_gradient"
android:minHeight="#dimen/min_btn_height">
<TextView
android:id="#+id/tv_invite_more_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="#dimen/eight_dp"
android:text="Add Photo"
android:textColor="#4ED9CA"
android:textAppearance="#style/TextAppearance.SFSemibold"
android:textSize="14sp" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/tv_invite_more_bottom"
android:src="#drawable/ic_add" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:maxHeight="20dp"
android:maxWidth="20dp"
android:layout_width="40dp"
android:background="#android:color/transparent"
android:layout_height="40dp"
android:src="#drawable/icon_bullet_list"
android:id="#+id/action_bulleted" />
<ImageButton
android:maxHeight="20dp"
android:maxWidth="20dp"
android:background="#android:color/transparent"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/icon_numbered_list"
android:id="#+id/action_unordered_numbered" />
</LinearLayout>
</RelativeLayout>
I would like my bottom layour above soft keyboard but it is having issue. Adjustpan doesn't work here.