由网友(桃花劫)分享简介:我希望能够滚动的CollapsingToolbarLayout内的ImageView的。那么,如何这将是可能的,以及如何设置图像视图的起始高度?我的ImageView的高度是280P,在我要显示200P的活动开始,然后我可以向下滚动才能看到图像的其余部分。我所看到的WhatsApp的应用程序类似的东西。下面是一个链接,...
我希望能够滚动的CollapsingToolbarLayout内的ImageView的。那么,如何这将是可能的,以及如何设置图像视图的起始高度?
我的ImageView的高度是280P,在我要显示200P的活动开始,然后我可以向下滚动才能看到图像的其余部分。我所看到的WhatsApp的应用程序类似的东西。
下面是一个链接,看看有什么我想要的:
我的code:
< XML版本=1.0编码=UTF-8&GT?;
< android.support.design.widget.CoordinatorLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
的xmlns:工具=http://schemas.android.com/tools机器人:layout_width =match_parent
机器人:layout_height =match_parent机器人:fitsSystemWindows =真
工具:上下文=com.example.yasser.version6.Profile>
< android.support.design.widget.AppBarLayout机器人:ID =@ + ID / app_bar
机器人:fitsSystemWindows =真正的机器人:layout_height =@扪/ app_bar_height
机器人:layout_width =match_parent安卓主题=@风格/ MyMaterialTheme.AppBarOverlay>
< android.support.design.widget.CollapsingToolbarLayout机器人:ID =@ + ID / toolbar_layout
机器人:fitsSystemWindows =真正的机器人:layout_width =match_parent
机器人:layout_height =match_parent应用程序:layout_scrollFlags =滚动| exitUntilCollapsed
应用程序:contentScrim =?ATTR / colorPrimary>
< ImageView的
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:scaleType =centerCrop
机器人:SRC =@可绘制/ TOF/>
< android.support.v7.widget.Toolbar机器人:ID =@ + ID /工具栏
机器人:layout_height =?ATTR / actionBarSize机器人:layout_width =match_parent
应用程序:layout_collapseMode =针
应用程序:popupTheme =@风格/ MyMaterialTheme.PopupOverlay/>
< /android.support.design.widget.CollapsingToolbarLayout>
< /android.support.design.widget.AppBarLayout>
<包括
机器人:ID =@ + ID /内容
布局=@布局/ content_profile/>
< /android.support.design.widget.CoordinatorLayout>
内容简介code:
< XML版本=1.0编码=UTF-8&GT?;
< android.support.v4.widget.NestedScrollView
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
的xmlns:程序=http://schemas.android.com/apk/res-auto
应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior
的xmlns:card_view =http://schemas.android.com/apk/res-auto
工具:舒=@布局/ activity_profile机器人:layout_width =match_parent
机器人:layout_height =match_parent工具:上下文=com.example.yasser.version6.Profile>
< /android.support.v4.widget.NestedScrollView>
解决方案
cheesesquare 实现您的要求
这是cheesesquare布局
< XML版本=1.0编码=UTF-8&GT?;
< android.support.design.widget.CoordinatorLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的>
< android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =@扪/ detail_backdrop_height
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
机器人:fitsSystemWindows =真正的>
< android.support.design.widget.CollapsingToolbarLayout
机器人:ID =@ + ID / collapsing_toolbar
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_scrollFlags =滚动| exitUntilCollapsed
机器人:fitsSystemWindows =真
应用程序:contentScrim =?ATTR / colorPrimary
应用程序:expandedTitleMarginStart =48dp
应用程序:expandedTitleMarginEnd =64dp>
< ImageView的
机器人:ID =@ + ID /背景
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:scaleType =centerCrop
机器人:fitsSystemWindows =真
应用程序:layout_collapseMode =视差/>
< android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
应用程序:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
应用程序:layout_collapseMode =针/>
< /android.support.design.widget.CollapsingToolbarLayout>
< /android.support.design.widget.AppBarLayout>
< android.support.v4.widget.NestedScrollView
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior>
<的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
机器人:paddingTop =24dp>
< android.support.v7.widget.CardView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_margin =@扪/ card_margin>
<的LinearLayout
风格=@风格/ Widget.CardContent
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=信息
机器人:textAppearance =@风格/ TextAppearance.AppCompat.Title/>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ cheese_ipsum/>
< / LinearLayout中>
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =@扪/ card_margin
机器人:layout_marginLeft =@扪/ card_margin
机器人:layout_marginRight =@扪/ card_margin>
<的LinearLayout
风格=@风格/ Widget.CardContent
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=朋友
机器人:textAppearance =@风格/ TextAppearance.AppCompat.Title/>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ cheese_ipsum/>
< / LinearLayout中>
< /android.support.v7.widget.CardView>
< android.support.v7.widget.CardView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =@扪/ card_margin
机器人:layout_marginLeft =@扪/ card_margin
机器人:layout_marginRight =@扪/ card_margin>
<的LinearLayout
风格=@风格/ Widget.CardContent
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=相关
机器人:textAppearance =@风格/ TextAppearance.AppCompat.Title/>
<的TextView
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ cheese_ipsum/>
< / LinearLayout中>
< /android.support.v7.widget.CardView>
< / LinearLayout中>
< /android.support.v4.widget.NestedScrollView>
< android.support.design.widget.FloatingActionButton
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =WRAP_CONTENT
应用程序:layout_anchor =@ ID / appbar
应用程序:layout_anchorGravity =底部|右|结束
机器人:SRC =@可绘制/ ic_discuss
机器人:layout_margin =@扪/ fab_margin
机器人:可点击=真/>
< /android.support.design.widget.CoordinatorLayout>
I want to be able to scroll on the ImageView inside the CollapsingToolbarLayout. So how that would be possible, and How to set a starting height of that Image view?
My ImageView height is 280p, at the start of the activity I want to show 200p and then I can scroll down to see the rest of the Image. I have seen something similar in WhatsApp application.
Here is a link to see what I want :
My code :
<?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" android:fitsSystemWindows="true"
tools:context="com.example.yasser.version6.Profile">
<android.support.design.widget.AppBarLayout android:id="@+id/app_bar"
android:fitsSystemWindows="true" android:layout_height="@dimen/app_bar_height"
android:layout_width="match_parent" android:theme="@style/MyMaterialTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout"
android:fitsSystemWindows="true" android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/tof" />
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize" android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/MyMaterialTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/content"
layout="@layout/content_profile" />
</android.support.design.widget.CoordinatorLayout>
Content profile code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
tools:showIn="@layout/activity_profile" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context="com.example.yasser.version6.Profile">
</android.support.v4.widget.NestedScrollView>
解决方案
cheesesquare implement your Request
this is a layout in cheesesquare
<?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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
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="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Info"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Friends"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Related"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<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>
相关推荐
最新文章