2014-11-10 23 views
7

Yakın zamanda AppCompat 21'in yeni bileşenleriyle uğraşmaya ve Materyal Tasarımı uygulamasına başladım. Şu anda, bir Araç Çubuğu ile bir ActionBarActivity sahibiyim ve bir RecyclerView TextView öğelerini içeren bir parçayı barındırmaya çalışıyorum (sadece Recycler'ı test etmek için). Ben öğeler görüntülenen var, ama her görünümde metin kesiliyor ve tüm Recycler şöyle Araç kapsayan: Gördüğünüz gibiParça içeriği üst üste bindiriliyor Araç Çubuğu

e description here

, üç TextView'lar vardır. Metni yarı yarıya kesilmiş ve Araç Çubuğunun üstündedir (Bildiğim Hiçbir Başlık). TextView öğesi düzenleri, Fragman'ın düzeni olan RecyclerView düzeninde bulunur. Üst Etkinliğin bir FrameLayout -> Araç Çubuğu, FrameLayout. Fragmanı Activity'ın alt FrameLayout'una ekliyorum. İşte XML var:

Recyclerin Her görünümü:

<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 düzeni, Fragment düzeni geçerli:

<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> 

Ve ebeveyn etkinlik'ın düzeni:

<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> 

Bunun basit bir şey olması gerektiğini biliyorum ama bir süreliğine şaka yaptım, çifte çeşitli şeyleri denemeye çalışıyorum. il.

cevap

8

Üst üst öğe olarak FrameLayout yerine RelativeLayout kullanın. Sonra sadece layout_above gibi bağımlılıkları Toolbar veya fragman konteyneri için layout_below ekleyin.

21

uygulamayı eklemesi unutmayın: layout_behavior = "@ string/appbar_scrolling_view_behavior" içerik düzeni

<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.v7.widget.Toolbar 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     <android.support.design.widget.TabLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

</android.support.design.widget.CoordinatorLayout> 
+2

Bu doğru yanıt olmalıdır için ... – josemigallas

İlgili konular