首先很抱歉提出另一个类似的问题。但其他问题都无法解决我的挑战。我在这里创建了一个github项目 https://github.com/winster/collapsingtoolbar
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
android:layout_above="@+id/footer">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/AppTheme.AppBarOverlay"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
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">
<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>
<include layout="@layout/content_scrolling" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5"
android:background="@color/colorPrimary"
android:alpha="1"
android:layout_alignParentBottom="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<EditText android:id="@+id/data"
android:layout_width="0dp"
android:layout_height="24dp"
android:hint="Enter data"
android:paddingLeft="10dp"
android:background="@null"
android:layout_marginRight="10dp"
android:layout_marginLeft="16dp"
android:lines="1"
android:layout_weight="3" />
<Button android:id="@+id/btn_send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:text="SEND"
android:textSize="16dp"
android:textColor="@color/colorPrimary" />
</LinearLayout>
</RelativeLayout>
<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:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:scrollbars="vertical" />
</RelativeLayout>
public class ScrollingActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private MyAdapter mAdapter;
private ArrayList<Card> arrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
arrayList = new ArrayList<>();
mAdapter = new MyAdapter(this, arrayList);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
}
@Override
protected void onResume() {
super.onResume();
for(int i=0;i<60;++i) {
arrayList.add(new Card("TEXT "+i));
}
mAdapter.notifyDataSetChanged();
if (mAdapter.getItemCount() > 1) {
((LinearLayoutManager)recyclerView.getLayoutManager()).setStackFromEnd(true);
recyclerView.getLayoutManager().smoothScrollToPosition(recyclerView, null, mAdapter.getItemCount() - 1);
//recyclerView.scrollToPosition(mAdapter.getItemCount()-1);
}
}
}
<activity
android:name=".ScrollingActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan">
现在有3个问题
答案 0 :(得分:0)
删除第android:fitsSystemWindows="true"
行
并删除状态栏颜色或将颜色从透明颜色更改为某些颜色 Valus / styles.xml(v21)中的其他颜色和变化。
希望这可能有助于你
如果没有尝试更改app:layout_scrollFlags="scroll|exitUntilCollapsed"
到app:layout_scrollFlags="scroll|exitUntilCollapsed"|snap