朋友。好几天我一直在解决这个问题 - 如何去除屏幕底部的空白区域。工具栏是在片段中创建的,由于未知原因,RecyclerView会在底部留下空白区域,如工具栏大小。请帮帮我。
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="600dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/grey"
android:fitsSystemWindows="true"
android:elevation="5dp">
<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"
app:contentScrim="@color/bir"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<SurfaceView
android:id="@+id/main.surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/icon"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/ic_launcher"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView3"
android:text="@string/app_name"
android:textColor="@color/red"
android:textSize="80dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:typeface="serif" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Stream 'em All!"
android:id="@+id/textView4"
android:textColor="@color/red"
android:textSize="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="67dp"
android:layout_marginEnd="67dp"
android:layout_marginBottom="91dp"
android:typeface="serif" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:elevation="5dp" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/stream_list"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton
android:layout_height="80dp"
android:layout_width="80dp"
android:layout_margin="@dimen/activity_horizontal_margin"
android:src="@drawable/ic_float"
app:layout_anchor="@id/main.appbar"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="com.example.shpp.videoapp.Utils.FABBehavior"
android:id="@+id/start_button"
android:elevation="5dp"/>
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (mView != null)
return mView;
mView = inflater.inflate(R.layout.welcome_fragment, null);
findViews();
return mView;
}
private void findViews() {
mRecyclerView = (RecyclerView) mView.findViewById(R.id.stream_list);
mSurface = (SurfaceView) mView.findViewById(R.id.main_surface);
mFloatButton = (FloatingActionButton) mView.findViewById(R.id.start_button);
mAppBarLayout = (AppBarLayout) mView.findViewById(R.id.main_appbar);
}
private void initViews() {
mFloatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCenter.getInstance().generateEvent(Event.GO_TO_STREAM, null);
}
});
LinearLayoutManager llm = new LinearLayoutManager(this.getContext());
StreamListDataProvider mStreamListDataProvider = new StreamListDataProvider(this.getContext());
StreamListAdapter mArapter = new StreamListAdapter(this.getContext(), mStreamListDataProvider);
mRecyclerView.setLayoutManager(llm);
mRecyclerView.setAdapter(mArapter);
mRecyclerView.setHasFixedSize(true);
SurfaceHolder mSurfaceHolder = mSurface.getHolder();
HolderCallback holderCallback = new HolderCallback();
mSurfaceHolder.addCallback(holderCallback);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
@Override
public void onResume() {
super.onResume();
mAppBarLayout.setExpanded(false);
initViews();
mCamera = Camera.open(ZERO);
}
@Override
public void onPause() {
super.onPause();
mCamera.stopPreview();
mCamera.release();
}
@Override
public void onStop() {
super.onStop();
}`