2015-07-28 3 views
0

Я изучаю материал Android из видео Slidenerd на Youtube. У меня возникла проблема, когда вы научитесь делать Recycler View на Drawer. Но позиция Recycler View не может быть снизу изображения. Я хочу бросить это после ImageView, как другое приложение Material Design. Посмотрим на скриншот.Recycler View Position Bottom of ImageView

enter image description here

Это мой код:

fragment_navigation_drawer.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#EEE" 
    tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment"> 
    <LinearLayout 
     android:id="@+id/containerDrawerImage" 
     android:background="#F88C00" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    <!-- TODO: Update blank fragment layout --> 
    <ImageView 
     android:layout_width="280dp" 
     android:layout_height="140dp" 
     android:layout_marginBottom="18dp" 
     android:src="@drawable/bg_galungan" 
     /> 


    </LinearLayout> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/drawer_list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    </android.support.v7.widget.RecyclerView> 


</FrameLayout> 

custom_row.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:padding="8dp" 
     android:id="@+id/listIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_bookmark1" 
     android:layout_gravity="center_vertical" 
     /> 
    <TextView 
     android:id="@+id/listText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Doa Sehari-hari" 
     android:layout_gravity="center_vertical" 
     /> 
</LinearLayout> 

Activity_main.xml

<android.support.v4.widget.DrawerLayout 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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout 
     android:fitsSystemWindows="true" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MainActivity" > 

     <include android:id="@+id/app_bar" 
      layout="@layout/app_bar" style="@style/AppTheme.Base" /> 

     <TextView 
      android:layout_below="@+id/app_bar" 
      android:text="@string/hello_world" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    </RelativeLayout> 

    <fragment 
     android:layout_width="@dimen/nav_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:id="@+id/fragment_navigation_drawer" 
     app:layout="@layout/fragment_navigation_drawer" 
     android:name="com.balinez.wdharmana.doahindu.NavigationDrawerFragment" 
     tools:layout="@layout/fragment_navigation_drawer" /> 


</android.support.v4.widget.DrawerLayout> 

Поделитесь, если у вас есть такая же проблема. Благодарим за продвижение!

ответ

0

Если это действительно не нужно пользователю FrameLayout в качестве вашего родителя, вы можете использовать RelativeLayout, как я использовал.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#EEE" 

      tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment"> 
    <LinearLayout 
     android:id="@+id/containerDrawerImage" 
     android:background="#F88C00" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     > 

     <!-- TODO: Update blank fragment layout --> 
     <ImageView 
      android:layout_width="280dp" 
      android:layout_height="140dp" 
      android:layout_marginBottom="18dp" 
      android:src="@drawable/beach" 
      /> 


    </LinearLayout> 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/drawer_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/containerDrawerImage" 
     > 
    </android.support.v7.widget.RecyclerView> 


</RelativeLayout> 
+0

Спасибо :) это работает – Dharmana