2016-04-12 10 views
1

私は問題は、リサイクラーが高さを持っていないと思います。だから私のパーセントレイアウトは100%で '0'の高さを埋めることはできません RecyclerViewのすべての子の高さを取得するには?リサイクラー(percentLayout)のAndroid PercentRelativeLayoutはRecyclerViewに表示されません

内容:

<android.support.percent.PercentRelativeLayout 
     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="100dp" 
     android:background="#000000"> 

    <TextView 
     app:layout_widthPercent="5%" 
     app:layout_heightPercent="100%" 
     app:layout_marginTopPercent="5%" 
     app:layout_marginLeftPercent="2%" 
     app:layout_marginRightPercent="75%" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Medium Text" 
     android:id="@+id/txt_roomname_map" 

     android:background="#3c64f6" 
     android:textColor="#ffffff" 

     /> 
    <TextView 
     app:layout_widthPercent="35%" 
     app:layout_heightPercent="100%" 
     app:layout_marginTopPercent="5%" 
     app:layout_marginLeftPercent="13%" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Medium Text" 
     android:id="@+id/txt_weapons_in_room_map" 
     android:background="#3c64f6" 
     android:textColor="#ffffff" 

    /> 

    <TextView 
     app:layout_widthPercent="35%" 
     app:layout_heightPercent="100%" 
     app:layout_marginTopPercent="5%" 
     app:layout_marginLeftPercent="52%" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Medium Text" 
     android:id="@+id/txt_weapons_in_room_map2" 
     android:background="#3c64f6" 
     android:textColor="#ffffff"/> 

    <TextView 
     app:layout_widthPercent="5%" 
     app:layout_heightPercent="100%" 
     app:layout_marginTopPercent="5%" 
     app:layout_marginLeftPercent="93%" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Medium Text" 
     android:id="@+id/txt_roomname_map2" 
     android:background="#3c64f6" 
     android:textColor="#ffffff" /> 
</android.support.percent.PercentRelativeLayout> 

RecyclerLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    android:background="#000000"> 



    <android.support.v7.widget.RecyclerView 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:id="@+id/recyclerview" 
     android:layout_below="@+id/imageView3" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="50dp" 
     android:id="@+id/imageView3" 

     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

どうもありがとう!

+0

誰かが私を助けることができますか? – Jendrik

答えて

0

レイアウト項目からRecyclerViewの高さにアクセスできないため、PercentRelativeLayoutの高さを画面のパーセントとして設定することはできません。

しかし、幅を100%に設定し、layout_aspectRatioを使用することができます。

関連する問題