在我的应用程序中,我想实现Whatsapp主页,如可折叠工具栏.也就是说,在向下滚动列表时,工具栏应该向上,并且选项卡应该固定在顶部.我怎样才能做到这一点?
这是我的appbar布局
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/appbarLayout"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/collapsibleToolBarLayout"
android:fitsSystemWindows="true"
app:titleEnabled="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
app:tabTextColor="@color/product_page_btn_grey"
app:tabSelectedTextColor="@color/upcomer_background_red"
app:tabIndicatorColor="@color/upcomer_background_red"
android:layout_gravity="bottom"
app:layout_scrollFlags="scroll|enterAlways"
app:tabContentStart="72dp" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.9"
android:background="@color/upcomer_background_red"
app:popupTheme="@style/AppTheme.PopupOverlay" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_image_view"
android:contentDescription="@null"
android:layout_gravity="start|center_vertical"
android:visibility="gone"
android:src="@drawable/title"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/title_layout"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/toolbarText"
style="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/send_button"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:text="@string/send_text"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
现在TabLayout不可见,即使下面的视图寻呼机中的列表滚动,工具栏也会保留在那里.请帮助.
我想知道RecylerView的swapAdapter和notifyDatasetChanged方法有什么区别?修改数据时哪一个更好用?
我尝试将项目中的compileSdkVersion设置为23并更新了以下库:
com.android.support:appcompat-v7:23.1.1com.android.support:recyclerview-v7:23.1.1com.android.support:cardview-v7:23.1.1从那时起,我在导入时遇到错误 android.support.v7.internal.widget.TintImageView
任何人都可以告诉我为什么会这样?TintImageView包的任何变化?请帮助.
我正在使用Studio Preview 2.0
我需要在向上滚动RecyclerView时实现分页.我正面临一些问题,因为在向第0个位置添加内容并通知适配器时,recyclerview会自动滚动到顶部.有没有办法禁用这种行为?
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
setFields(viewHolder, data);
if (position == 0 && getParentFragment().hasPrevious()) {
getParentFragment().callPreviousPage();
}
}
Run Code Online (Sandbox Code Playgroud)
where setFields(viewHolder, data);方法将值设置为不同的字段.
if (position == 0 && getParentFragment().hasPrevious()) {
getParentFragment().callPreviousPage();
}
Run Code Online (Sandbox Code Playgroud)
以上代码用于在回收站视图的位置达到0(分页)时调用Web服务.
public synchronized void setList(final List<TournamentsData> list) {
this.list.addAll(0, list);
notifyDataSetChanged();
}
Run Code Online (Sandbox Code Playgroud)
以上是将从Web服务获取的数据加载到适配器的方法.
非常感谢你提前.