I have the following layout :
<?xml version="1.0" encoding="utf-8"?>
<nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScaleOpen="0.87"
app:marginFactor="0.7">
<nl.psdcompany.duonavigationdrawer.views.DuoMenuView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_menu_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:tag="#string/tag_menu"
app:footer="#layout/drawer_footer"
app:header="#layout/drawer_header" />
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="#string/tag_content"
android:translationZ="8dp">
<include layout="#layout/layout_toolbar" />
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout>
The include layout is
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:translationZ="4dp"
app:contentScrim="#color/colorPrimary"
app:layout_scrollFlags="exitUntilCollapsed|snap"
app:scrimAnimationDuration="250">
<!--
Toolbar Collapsing Layout
-->
<LinearLayout
android:id="#+id/collapsing_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="32dp"
android:layout_marginStart="32dp"
android:layout_marginTop="56dp"
android:orientation="vertical"
android:visibility="visible"
app:layout_collapseMode="parallax">
<TextView
android:id="#+id/collapsing_toolbar_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textColor="#color/white"
android:textSize="24sp"
android:visibility="visible" />
<TextView
android:id="#+id/collapsing_toolbar_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="visible" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/transparent"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin">
<RelativeLayout
android:id="#+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="#dimen/margin_medium"
android:paddingStart="#dimen/margin_medium">
<!--
Toolbar TOP Layout
-->
<RelativeLayout
android:id="#+id/toolbar_top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:minHeight="?attr/actionBarSize">
<RelativeLayout
android:id="#+id/default_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:visibility="visible">
<!-- Starting icons container -->
<FrameLayout
android:id="#+id/toolbar_left_icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/margin_small">
<ImageView
android:id="#+id/toolbar_hamburger"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:tint="#color/white"
android:visibility="gone"
app:srcCompat="#drawable/ic_burger_menu_white" />
<ImageView
android:id="#+id/toolbar_start_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:tint="#android:color/white"
android:visibility="gone"
app:srcCompat="#drawable/ic_back_button_white" />
<TextView
android:id="#+id/toolbar_start_text_icon"
fontPath="#string/font_sf_ui_display_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Cancel"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_medium"
android:visibility="gone"
app:srcCompat="#drawable/ic_back_button_white" />
</FrameLayout>
<!-- Step Progress Bar -->
<FrameLayout
android:id="#+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#id/toolbar_left_icon_container"
android:visibility="gone"/>
<!-- Main title centered in the toolbar -->
<LinearLayout
android:id="#+id/toolbar_title_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/toolbar_main_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="View Offer"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="15sp"
android:visibility="gone" />
<TextView
android:id="#+id/toolbar_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:text="last visit on 15-03"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="gone" />
</LinearLayout>
<!-- Secondary end icon -->
<ImageView
android:id="#+id/toolbar_secondary_end_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/margin_small"
android:layout_toStartOf="#+id/toolbar_end_icon_container"
android:visibility="gone"
app:srcCompat="#drawable/ic_share_white" />
<!-- Primary end icon container-->
<FrameLayout
android:id="#+id/toolbar_end_icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/toolbar_primary_end_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:visibility="gone"
app:srcCompat="#drawable/ic_share_white" />
<!-- Badge counter container -->
<FrameLayout
android:id="#+id/toolbar_badge_counter_container"
android:layout_width="28dp"
android:layout_height="28dp"
android:visibility="gone">
<ImageView
android:id="#+id/toolbar_badge_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:padding="4dp"
android:visibility="gone"
app:srcCompat="#drawable/ic_bell_notifications" />
<TextView
android:id="#+id/toolbar_badge_counter"
fontPath="#string/font_sf_ui_display_medium"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="end"
android:background="#drawable/circle_blue"
android:gravity="center"
android:text="3"
android:textColor="#color/white"
android:textSize="9sp"
android:visibility="gone" />
</FrameLayout>
<TextView
android:id="#+id/toolbar_right_text_icon"
fontPath="#string/font_sf_ui_display_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_medium"
android:visibility="gone" />
</FrameLayout>
<Button
android:id="#+id/change_postal_code_button"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_small"
android:layout_toLeftOf="#+id/toolbar_end_icon_container"
android:background="#drawable/rounded_background_blue"
android:drawablePadding="#dimen/margin_small"
android:drawableStart="#drawable/ic_navigation_white"
android:minHeight="0dp"
android:paddingBottom="#dimen/margin_small"
android:paddingLeft="#dimen/margin_small_medium"
android:paddingRight="#dimen/margin_small_medium"
android:paddingTop="#dimen/margin_small"
android:text="1234 AA, Amsterdam"
android:textAllCaps="false"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
<!--
Toolbar BOTTOM Layout
-->
<LinearLayout
android:id="#+id/toolbar_bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar_top_container"
android:orientation="vertical"
android:paddingBottom="#dimen/margin_medium"
android:visibility="gone">
<TextView
android:id="#+id/toolbar_bottom_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="View Offer"
android:textColor="#color/white"
android:textSize="24sp"
android:visibility="gone" />
<TextView
android:id="#+id/toolbar_bottom_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:text="last visit on 15-04"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="gone" />
<include
android:id="#+id/search_toolbar"
layout="#layout/layout_search_offers" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
It consists of an AppBarLayout with an CollapsingToolbarLayout which has as the first child a Linear that's acting as the collapse layout and a Toolbar layout which holds the top bar and a static bottom one when I need a bottom non collapsing toolbar.
The collapsing works great, I can set my ToolBar to have only the top layout or only the bottom but when I change the visibility of items to Gone the AppBarLayout(or the CollapsingToolbarLayout) doesn't resize and keeps the spacing.
Example image :
After fragment change (I set views to Gone to reset the layouts)
Thank you for your time;
Related
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">
In our chat app new message start first. For see old message user scroll up. For this we set reverseLayout true.
Ex: LayoutManager reverse so 0 position is botttom. when user scroll for old message suppose position is 10 . so i want to hide toolbar.when user go below from 10 position to 9 position i want to show toolbar.
LinearLayoutManager linearLayoutManager = new WrapContentLinearLayoutManager(context);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
linearLayoutManager.setReverseLayout(true);
We want to hide collapsing toolbar when user scroll up for fetch old message and show collapsing toolbar when user scroll down.
Any hints on how to achieve this?
XML Code as below :
<?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/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/whole_background_color"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBackgroundWall"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlChatMessageSendView">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<include
android:id="#+id/rlZoneDetail"
layout="#layout/include_layout_zone_option" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="com.gochat.uIUtil.FixScrollingFooterBehavior">
<RelativeLayout
android:id="#+id/rel_root_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlChat"
android:paddingBottom="#dimen/margin_five">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewChat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="none"
android:visibility="visible"
tools:listitem="#layout/chat_adapter_message_layout" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:theme="#style/AppTheme.ProgressBarColor"
android:visibility="gone" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvFollow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="#dimen/padding_five"
android:layout_marginTop="#dimen/padding_ten"
android:background="#drawable/background_login_signup_small_radius"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="#dimen/padding_five"
android:paddingLeft="#dimen/padding_twenty"
android:paddingRight="#dimen/padding_twenty"
android:paddingTop="#dimen/padding_five"
android:singleLine="true"
android:text="#string/start_follow"
android:textAllCaps="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textSize="#dimen/text_size_fifteen"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llAnnounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/recyclerViewChat"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/padding_five"
android:layout_marginRight="#dimen/padding_five"
android:layout_marginTop="#dimen/padding_five"
android:background="#drawable/background_login_signup_small_radius"
android:gravity="center"
android:visibility="gone">
<ImageView
android:layout_width="#dimen/padding_thirteen"
android:layout_height="#dimen/padding_thirteen"
android:layout_marginLeft="#dimen/margin_seven"
android:layout_marginStart="#dimen/margin_seven"
android:src="#drawable/iv_white_shout" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvAnnouncement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_twenty"
android:layout_marginLeft="#dimen/margin_ten"
android:layout_marginRight="#dimen/margin_twenty"
android:layout_marginStart="#dimen/margin_ten"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="#dimen/padding_five"
android:paddingTop="#dimen/padding_five"
android:singleLine="true"
android:text="#string/announce_text"
android:textAllCaps="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textSize="#dimen/text_size_thirteen"
android:visibility="visible" />
<ImageView
android:layout_width="#dimen/padding_thirteen"
android:layout_height="#dimen/padding_thirteen"
android:layout_marginEnd="#dimen/margin_seven"
android:layout_marginRight="#dimen/margin_seven"
android:src="#drawable/iv_white_send" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/rlChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/bg_bottombar"
android:orientation="vertical"
android:visibility="visible"
app:layout_behavior="com.gochat.uIUtil.FixScrollingFooterBehavior">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/onedp"
android:background="#color/create_zone_divider_color_whatsapp" />
<RelativeLayout
android:id="#+id/rl_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bottom_tab"
android:padding="#dimen/padding_seven"
android:visibility="visible">
<RelativeLayout
android:id="#+id/rlAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:paddingBottom="#dimen/padding_ten"
android:paddingRight="#dimen/margin_eight"
android:paddingTop="#dimen/padding_ten">
<ImageView
android:id="#+id/ivAdd"
android:layout_width="#dimen/margin_twenty"
android:layout_height="#dimen/margin_twenty"
android:layout_centerVertical="true"
android:src="#drawable/iv_add_blue" />
</RelativeLayout>
<ImageView
android:id="#+id/ivFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/iv_add_blue"
android:visibility="gone" />
<ImageView
android:id="#+id/ivMenuOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rel_message"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/margin_twenty"
android:layout_marginRight="#dimen/margin_twenty"
android:layout_toLeftOf="#+id/ivFullscreen"
android:layout_toStartOf="#+id/ivFullscreen"
android:src="#drawable/iv_menu_grid"
android:visibility="gone" />
<TextView
android:id="#+id/tv_Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="TITLE"
android:textStyle="bold"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/rel_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/rlAdd"
android:layout_toLeftOf="#+id/iv_send"
android:layout_toRightOf="#+id/rlAdd"
android:layout_toStartOf="#+id/iv_send"
android:background="#drawable/chat_send_message_background"
android:visibility="visible">
<RelativeLayout
android:id="#+id/rl_chat_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<EditText
android:id="#+id/et_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_ten"
android:layout_marginLeft="#dimen/margin_ten"
android:layout_marginRight="#dimen/margin_ten"
android:layout_marginStart="#dimen/margin_ten"
android:background="#null"
android:hint="#string/type_messsage"
android:inputType="textMultiLine"
android:maxLines="4"
android:padding="#dimen/padding_eight"
android:textColorHint="#color/hint_text_color"
android:textSize="#dimen/text_size_fifteen"
tools:text="zxnihxkbdfcdaaa" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/iv_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="#dimen/margin_five"
android:src="#drawable/iv_send_message_light"
android:visibility="invisible" />
<ImageView
android:id="#+id/iv_record"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="#dimen/margin_five"
android:src="#drawable/iv_audio_record"
android:visibility="visible" />
</RelativeLayout>
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#color/white"
android:padding="#dimen/padding_fifteen"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="#+id/rlChatMessageSendView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="#+id/llSpectatorZone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="#dimen/margin_ten"
android:background="#color/white"
android:orientation="horizontal"
android:padding="#dimen/padding_ten"
android:visibility="gone">
<TextView
android:id="#+id/tvSpectatorZone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/you_can_only_view_this_zone"
android:textColor="#color/unselected_item_color"
android:textSize="#dimen/text_size_seventeen" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Please try below link. It may solve your problem.
http://xmodulo.com/hide-show-toolbar-scrolling-android.html
Thanks !
I'm having issue with certain text views that stubbornly won't change color. I'm not sure why it's not working.
I have my color in a resource/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#FDCDB2</color>
<color name="colorPrimaryDark">#E2896B</color>
<color name="colorAccent">#FF4081</color>
<color name="mainBackground">#F6F5F5</color>
</resources>
I've attempted both hardcoding the color in the layout.xml file as well as dynamically setting the color:
descriptionHeader.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
and
android:textColor="#color/colorPrimaryDark"
notice in the image the text with the brown hue, that is the desired color. "Description", its body, and "Instructions" have decided to just be a light grey
below is my code for the 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:fitsSystemWindows="true"
android:orientation="vertical">
<!--make whole layout scrollable-->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<!--nested view can only have one child-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:textColor="#color/colorPrimary"
>
<!-- main image of the brew method-->
<ImageView
android:id="#+id/topImageIV"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center|top"
android:background="#color/colorPrimary"
android:focusableInTouchMode="true" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--layout for the brew parameteres-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/brew_method_parameters"
android:orientation="horizontal"
android:padding="8dp"
android:weightSum="3">
<!--layout for the weight-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="vertical">
<!--top row of the weight includes image-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:orientation="horizontal">
<!--weight image icon-->
<ImageView
android:id="#+id/weight_icon_IV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:focusableInTouchMode="true"
android:src="#drawable/ic_weight" />
<!--weight parameter set dynamically-->
<TextView
android:id="#+id/TV_servingDose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:hint="16 g"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
<!--serving size set dynamically-->
<TextView
android:id="#+id/TV_servingNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="1 Serving"
android:paddingLeft="12dp"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
<!--layout for time requirement-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="vertical">
<!--top row of time requirement-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:orientation="horizontal">
<!--time icon-->
<ImageView
android:id="#+id/timer_icon_IV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:focusableInTouchMode="true"
android:src="#drawable/ic_clock" />
<!--brew time set dynamically-->
<TextView
android:id="#+id/TV_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="4:00"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
<!--brew time label-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="15dp"
android:text="Brew Time"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
<!--layout for grind size-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="vertical">
<!--top row of grind size includes image-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:orientation="horizontal">
<!--icon for grind-->
<ImageView
android:id="#+id/grind_icon_IV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:focusableInTouchMode="true"
android:src="#drawable/ic_grinder" />
<!--grind description set dynamically-->
<TextView
android:id="#+id/TV_grindSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="#string/grind_size_coarse"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
<!--grind setting description-->
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="12dp"
android:text="#string/grind_setting"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<!--description of brewmethod layout-->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical"
app:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/mainBackground"
android:orientation="vertical">
<!--description label-->
<TextView
android:id="#+id/description_header_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/brew_method_description"
android:paddingStart="16dp"
android:textColor="#color/colorPrimaryDark"
android:textSize="24sp" />
<!--description text-->
<TextView
android:id="#+id/brew_method_description_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/bio_aeropress"
android:paddingBottom="8dp"
android:paddingRight="16dp"
android:paddingStart="16dp"
android:textColor="#color/colorPrimaryDark" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!--instructions label-->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical"
app:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/mainBackground"
android:orientation="vertical">
<TextView
android:id="#+id/brew_method_instructions_title_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorPrimaryDark"
android:hint="#string/brew_method_instructions"
android:paddingStart="16dp"
android:textSize="24sp" />
<!--instuctions recyclerview. set using InstructionListAdapter-->
<android.support.v7.widget.RecyclerView
android:id="#+id/rvInstructions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="0dp">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:titleTextColor="#color/colorPrimaryDark" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:backgroundTint="#color/colorPrimaryDark"
app:srcCompat="#android:drawable/ic_lock_idle_alarm" />
</android.support.design.widget.CoordinatorLayout>
Figured out what was going on:
In my text views with the color issue, I was using
android:hint="#string/brew_method_description
instead of
android:text="#string/brew_method_description
Switching setting the actual text enabled the color change.
I'm trying to implement bottom sheet that will overlap exactly a view not a
whole screen. Desirable
.
But here is actual result
end position
.
What I'm doing wrong?
Here is the code. I want to overlap Textview with id content_to_overlap.
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
android:gravity="center"
android:text="Text3" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:clipChildren="false"
android:clipToPadding="false"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-48dp" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Code Below is not perfect but is provided to give you an idea
Use anchor for fab
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
android:gravity="center"
android:text="Text3" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:anchor="#id/content_to_overlap" />
</android.support.design.widget.CoordinatorLayout>
i have a layout with swipeaRefreshLayout and a Toolbar(Both from v4 and v7 using v-21), but when i start the app the listview its hide, i only can see the toolbar like a actionbar.
This is my code:
<?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
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_toEndOf="#id/toolbar">
<ListView
android:id="#+id/questionList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/swipe_container"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#id/swipe_container"
android:background="#686868"
android:visibility="visible" />
<com.shamanland.fab.FloatingActionButton
android:id="#+id/btnNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="32dp" />
<LinearLayout
android:id="#+id/emptyData"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#686868"
android:clickable="true"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="4dp"
android:text="No hay elementos disponibles"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="4dp"
android:src="#android:drawable/ic_dialog_email" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
SwipeRefreshLayout can only have a single child view, wrap it's content in a linearlayout. That should solve your issue