【发布时间】:2014-11-10 01:14:18
【问题描述】:
我最近开始研究 AppCompat 21 的新组件并实现 Material Design。目前,我有一个带有工具栏的 ActionBarActivity 并试图让它托管一个包含 TextView 项目的 RecyclerView 的片段(只是为了测试 Recycler)。我有正在显示的项目,但是每个视图中的文本都被截断了,整个 Recycler 都像这样覆盖了工具栏:
如您所见,共有三个 TextView。他们的文本被中途截断,并覆盖在工具栏上(我不知道标题)。 TextView 项目布局包含在 RecyclerView 布局中,这是 Fragment 的布局。父Activity有一个FrameLayout -> Toolbar,FrameLayout。我将 Fragment 插入到 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"/>
Recycler布局,也就是Fragment的布局:
<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>
我知道这一定很简单,但我已经被它难住了一段时间,尝试了各种方法都无济于事。
【问题讨论】:
标签: android android-fragments android-toolbar