我最近开始尝试使用AppCompat 21的新组件并实现Material Design。目前,我有一个ActionBarActivity和一个Toolbar,并试图让它托管一个包含一些文本视图项目(仅为了测试Recycler)的片段。我已经显示了这些项,但每个视图中的文本被截断了,整个Recycler重叠在工具栏上,如下图所示:
https://istack.dev59.com/ARndR.webp 您可以看到,有三个TextViews。它们的文本被截断了一半,覆盖在工具栏上(没有标题)。TextView项目布局包含在RecyclerView布局中,后者是片段的布局。父活动有一个FrameLayout -> Toolbar,FrameLayout。我将片段插入到Activity的子FrameLayout中。以下是XML代码:
每个Recycler中的视图:
回收站布局,是片段的布局方式:
https://istack.dev59.com/ARndR.webp 您可以看到,有三个TextViews。它们的文本被截断了一半,覆盖在工具栏上(没有标题)。TextView项目布局包含在RecyclerView布局中,后者是片段的布局。父活动有一个FrameLayout -> Toolbar,FrameLayout。我将片段插入到Activity的子FrameLayout中。以下是XML代码:
每个Recycler中的视图:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="match_parent"
android:layout_height="48dp"
android:fontFamily="sans-serif"
android:paddingTop="16dp"
android:paddingBottom="20dp"
android:textSize="16sp"/>
回收站布局,是片段的布局方式:
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler_tasks"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="stuff.MainActivity$TaskFragment">
</android.support.v7.widget.RecyclerView>
父Activity的布局:
<FrameLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
我知道这一定是很简单的问题,但我已经被困扰了一段时间,尝试了各种方法都没有成功。