xml 使用制表符和viewpager合并工具栏....视图寻呼机包含recyclerView ....活动代码位于分叉存储库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 使用制表符和viewpager合并工具栏....视图寻呼机包含recyclerView ....活动代码位于分叉存储库相关的知识,希望对你有一定的参考价值。
//another collapsing bar with slider
//I must add my conten inside a NESTEDSCROLLVIEW ... or it wont work out .. then include this inside your coordinator layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="100dp"
android:background="@color/white_greyish"
tools:context=".appartmentdetails.ApartmentActivity"
tools:showIn="@layout/activity_apartmet"
>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="3dp">
<!--I made a relative layout and used alignParent and -->
<!--centerVertical to place them this way-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/price"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_price_ApartAct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="1200"
android:textSize="15dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="3dp">
<!--I made a relative layout and used alignParent and -->
<!--centerVertical to place them this way-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/city"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_city_ApartAct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="1200"
android:textSize="15dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="3dp">
<!--I made a relative layout and used alignParent and -->
<!--centerVertical to place them this way-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/address"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_address_ApartAct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="1200"
android:textSize="15dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="3dp">
<!--I made a relative layout and used alignParent and -->
<!--centerVertical to place them this way-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/numOfRooms"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_numRooms_ApartAct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="1200"
android:textSize="15dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp">
<!--I made a relative layout and used alignParent and -->
<!--centerVertical to place them this way-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/dumbTvDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/description"
android:textSize="15dp" />
<TextView
android:id="@+id/tv_desc_ApartAct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/dumbTvDesc"
android:gravity="end"
android:text="12dasdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd00"
android:textSize="15dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/baseBackground" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/baseBackground" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/baseBackground" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
// it contains FAB and Slider
<?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="com.projects.cactus.maskn.appartmentdetails.ApartmentActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarLayoutWithSliding"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include
layout="@layout/slider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_inside_collapsing"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_activity_apartment" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/appbarLayoutWithSliding" //refrence for appbar
app:layout_anchorGravity="bottom|end" ///position of fab
app:srcCompat="@android:drawable/ic_menu_call" />
</android.support.design.widget.CoordinatorLayout>
<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:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.TabLayout
android:id="@+id/detail_tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="?attr/colorPrimary"
app:layout_anchor="@+id/appbar"
app:layout_anchorGravity="bottom"
app:tabGravity="fill"
app:tabMode="fixed" />
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!--<include layout="@layout/nested_scrollview"/>-->
<!--<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_discuss"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"/>-->
</android.support.design.widget.CoordinatorLayout>
//there was a wrong version of this ... here is the log
The changes I made above are:
Move TabLayout out of CollapsingToolbarLayout and put it directly under CoordinatorLayout
Set these attributes inside TabLayout:
android:layout_gravity="bottom" - To make sure AppBarLayout doesn't overlap on TabLayout
app:layout_anchor="@+id/appbar" and app:layout_anchorGravity="bottom" - To make sure tabs appear below AppBarLayout
Also set android:layout_marginTop="?attr/actionBarSize" inside ViewPager to make sure TabLayout doesn't overlap any items in the list
以上是关于xml 使用制表符和viewpager合并工具栏....视图寻呼机包含recyclerView ....活动代码位于分叉存储库的主要内容,如果未能解决你的问题,请参考以下文章