CoordinatorLayout (Toolbar+NestedScrollView+BottomNavigationView) 问题
CoordinatorLayout (Toolbar+NestedScrollView+BottomNavigationView) issue
我正在使用 CoordinatorLayout 作为显示工具栏、NestedScrollView 和 BottomNavigationView 的根布局。我设计得很好,但 NestedScrollView 不在工具栏下,它是在工具栏后面开始的。
我正在使用下面的 XML
<?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"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical"
android:weightSum="8">
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// for menu view
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginTop="95dp"
android:background="@color/chartlayoutBgcolor"
android:id="@+id/infoAct"
android:layout_gravity="bottom|right"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data details"
android:textSize="15sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Max Data Date: NOV - 10"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Refresh Date : Nov - 11"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
</LinearLayout>
// Buttom Bar Buttons
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
对于工具栏 Xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="wrap_content"
android:background="@color/lineGray"
android:elevation="8dp"
android:divider="@android:color/transparent"
android:dividerHeight="0.0px"
android:clipToPadding="false"
android:clipChildren="false"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"
>
<android.support.v7.widget.Toolbar
android:id="@+id/tool"
android:layout_width="match_parent"
android:layout_height="80dp"
android:contentInsetLeft="5dp"
android:contentInsetStart="5dp"
app:contentInsetLeft="5dp"
app:contentInsetStart="5dp"
android:contentInsetRight="5dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
android:background="@color/colorPrimary"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="6">
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_weight="1.1"
android:foregroundGravity="center"
app:srcCompat="@drawable/watch" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center"
android:text="Thu,25 - Sep"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="Current"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="PriorYR"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_weight="1.2"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="Healthscore"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp"/>
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.v7.widget.CardView>
由于是新手 Android 我不知道如何解决这个问题。
由于您已明确将工具栏高度设置为 80dp
,因此将工具栏下方线性布局的上边距也设置为 80dp
。
android:layout_marginTop="80dp"
如下更改布局。
<?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"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical" >
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="80dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// for menu view
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginTop="95dp"
android:background="@color/chartlayoutBgcolor"
android:id="@+id/infoAct"
android:layout_gravity="bottom|right"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data details"
android:textSize="15sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Max Data Date: NOV - 10"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Refresh Date : Nov - 11"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
</LinearLayout>
// Buttom Bar Buttons
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
您应该将滚动行为设置为根 LinearLayout,只需使用下面的代码并使用 AppBarLayout 包装您的工具栏容器(如果尚未完成)
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical"
android:weightSum="8">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// Buttom Bar Buttons
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</android.support.design.widget.CoordinatorLayout>
我正在使用 CoordinatorLayout 作为显示工具栏、NestedScrollView 和 BottomNavigationView 的根布局。我设计得很好,但 NestedScrollView 不在工具栏下,它是在工具栏后面开始的。
我正在使用下面的 XML
<?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"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical"
android:weightSum="8">
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// for menu view
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginTop="95dp"
android:background="@color/chartlayoutBgcolor"
android:id="@+id/infoAct"
android:layout_gravity="bottom|right"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data details"
android:textSize="15sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Max Data Date: NOV - 10"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Refresh Date : Nov - 11"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
</LinearLayout>
// Buttom Bar Buttons
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
对于工具栏 Xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="wrap_content"
android:background="@color/lineGray"
android:elevation="8dp"
android:divider="@android:color/transparent"
android:dividerHeight="0.0px"
android:clipToPadding="false"
android:clipChildren="false"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"
>
<android.support.v7.widget.Toolbar
android:id="@+id/tool"
android:layout_width="match_parent"
android:layout_height="80dp"
android:contentInsetLeft="5dp"
android:contentInsetStart="5dp"
app:contentInsetLeft="5dp"
app:contentInsetStart="5dp"
android:contentInsetRight="5dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
android:background="@color/colorPrimary"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="6">
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_weight="1.1"
android:foregroundGravity="center"
app:srcCompat="@drawable/watch" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center"
android:text="Thu,25 - Sep"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="Current"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="PriorYR"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_weight="1.2"
android:orientation="vertical"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="Healthscore"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="123"
android:textStyle="bold"
android:textColor="@color/lineBlue"
android:textSize="13dp"/>
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="321"
android:textStyle="bold"
android:textColor="@color/textColor"
android:textSize="13dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="7dma"
android:textColor="@color/textColor"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.v7.widget.CardView>
由于是新手 Android 我不知道如何解决这个问题。
由于您已明确将工具栏高度设置为 80dp
,因此将工具栏下方线性布局的上边距也设置为 80dp
。
android:layout_marginTop="80dp"
如下更改布局。
<?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"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical" >
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="80dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// for menu view
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginTop="95dp"
android:background="@color/chartlayoutBgcolor"
android:id="@+id/infoAct"
android:layout_gravity="bottom|right"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Data details"
android:textSize="15sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Max Data Date: NOV - 10"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Refresh Date : Nov - 11"
android:textSize="13sp"
android:background="@color/chartlayoutBgcolor"
android:textColor="@color/lineBlue"
android:paddingLeft="15dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical|left"
android:layout_marginBottom="4dp"
/>
</LinearLayout>
// Buttom Bar Buttons
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
您应该将滚动行为设置为根 LinearLayout,只需使用下面的代码并使用 AppBarLayout 包装您的工具栏容器(如果尚未完成)
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.DashBoard_Activity"
android:orientation="vertical"
android:weightSum="8">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<include
layout="@layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"
android:weightSum="2.8">
// Scroll View
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="3">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/chartlayoutBgcolor"
android:descendantFocusability="blocksDescendants">
// Home and save button //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="10dp"
android:background="@color/topbarColor"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:layout_weight="1"
android:paddingLeft="10dp"
app:srcCompat="@drawable/ic_icon_home" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:paddingRight="10dp"
app:srcCompat="@drawable/ic_icon_save" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
// First chart //
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:layout_alignEnd="@+id/hc"
android:gravity="right">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day7"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="7D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border1"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border1"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day14"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day14"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="14D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_toLeftOf="@id/Border2"
android:padding="1dp"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Border2"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_toLeftOf="@id/Day21"
android:padding="1dp"
android:background="@color/lineOrange"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/Day21"
android:layout_width="26dp"
android:layout_height="20dp"
android:gravity="center_vertical|center"
android:text="21D"
android:textSize="10sp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="1dp"/>
</RelativeLayout>
</RelativeLayout>
// Second chart //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<com.highsoft.highcharts.Core.HIChartView
android:id="@+id/hc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
// Last label //
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:background="@android:color/transparent"
android:paddingTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="(To normalize weekday trend, Prior year = Current day-364 Example Monday VS Monday last year) "
android:textColor="@color/lineGreen"
android:textSize="@dimen/graphText"
android:lines="2"/>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</LinearLayout>
// Buttom Bar Buttons
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/lineGray"
app:menu="@menu/bottom_navigation">
</android.support.design.widget.BottomNavigationView>
</android.support.design.widget.CoordinatorLayout>