2017-08-31 93 views
-2

我一直在嘗試進行佈局。但在一些像api 25的android版本上。佈局.xml在某些android版本上無法正常工作

你能看到我在做什麼錯嗎?順便說一句,因爲我的代碼不適合在這裏下。 Android工作室不給我一個錯誤代碼或什麼的。它使我的.apk很好。所有頁面都在工作,但這不是。

'<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:orientation="vertical"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="@dimen/space16"> 
      <ImageView 
       android:id="@+id/iv_user" 
       android:layout_width="45dp" 
       android:layout_height="45dp" 
       android:background="@drawable/head"/> 
      <RatingBar 
       android:id="@+id/ratingBar" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_marginLeft="@dimen/space16" 
       android:layout_marginBottom="@dimen/space8" 
       android:rating="3" 
       android:numStars="5" 
       android:isIndicator="true" 
       style="@style/RatingBar" 
       android:layout_toRightOf="@id/iv_user"/> 
      <TextView 
       android:id="@+id/tv_username" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/ratingBar" 
       android:layout_alignLeft="@id/ratingBar" 
       android:text="Henrie, €12.- p/u" 
       android:textColor="@color/colorTextDark" 
       android:textSize="@dimen/h3" 
       android:textAppearance="@style/SemiBold"/> 
      <TextView 
       android:id="@+id/tv_date" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/ratingBar" 
       android:layout_marginLeft="@dimen/space8" 
       android:layout_toRightOf="@id/tv_username" 
       android:layout_alignBaseline="@id/tv_username" 
       android:text="Oudijzer handel" 

       android:textColor="@color/colorTextGrey" 
       android:textSize="12sp" 
       android:textAppearance="@style/Regular"/> 
      <TextView 
       android:id="@+id/tv_text_comment" 
       android:layout_width="wrap_content" 
       android:layout_marginTop="@dimen/space8" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/tv_username" 
       android:layout_alignLeft="@id/ratingBar" 
       style="@style/Text14Reg"/> 
     </RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="15dp" 
    android:paddingTop="96dp"> 
    <ImageView 
     android:id="@+id/iv_user1" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:background="@drawable/head2"/> 
    <RatingBar 
     android:id="@+id/ratingBar1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="@dimen/space16" 
     android:layout_marginBottom="@dimen/space8" 
     android:rating="4.5" 
     android:numStars="5" 
     android:isIndicator="true" 
     style="@style/RatingBar" 
     android:layout_toRightOf="@id/iv_user1"/> 
    <TextView 
     android:id="@+id/tv_username1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar1" 
     android:layout_alignLeft="@id/ratingBar1" 
     android:text="Hetty, €5.- p/u" 
     android:textColor="@color/colorTextDark" 
     android:textSize="@dimen/h3" 
     android:textAppearance="@style/SemiBold"/> 
    <TextView 
     android:id="@+id/tv_date1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar1" 
     android:layout_marginLeft="@dimen/space8" 
     android:layout_toRightOf="@id/tv_username1" 
     android:layout_alignBaseline="@id/tv_username1" 
     android:text="Haken met wol en andere stof" 
     android:textColor="@color/colorTextGrey" 
     android:textSize="12sp" 
     android:textAppearance="@style/Regular"/> 
    <TextView 
     android:id="@+id/tv_text_comment1" 
     android:layout_width="wrap_content" 
     android:layout_marginTop="@dimen/space8" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tv_username1" 
     android:layout_alignLeft="@id/ratingBar1" 
     style="@style/Text14Reg"/> 
</RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="15dp" 
    android:paddingTop="176dp"> 
    <ImageView 
     android:id="@+id/iv_user2" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:background="@drawable/head3"/> 
    <RatingBar 
     android:id="@+id/ratingBar2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="@dimen/space16" 
     android:layout_marginBottom="@dimen/space8" 
     android:rating="4.5" 
     android:numStars="5" 
     android:isIndicator="true" 
     style="@style/RatingBar" 
     android:layout_toRightOf="@id/iv_user2"/> 
    <TextView 
     android:id="@+id/tv_username2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar2" 
     android:layout_alignLeft="@id/ratingBar2" 
     android:text="Peter, €106.- p/u" 
     android:textColor="@color/colorTextDark" 
     android:textSize="@dimen/h3" 
     android:textAppearance="@style/SemiBold"/> 
    <TextView 
     android:id="@+id/tv_date2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar2" 
     android:layout_marginLeft="@dimen/space8" 
     android:layout_toRightOf="@id/tv_username2" 
     android:layout_alignBaseline="@id/tv_username2" 
     android:text="Professioneel APK keurder" 
     android:textColor="@color/colorTextGrey" 
     android:textSize="12sp" 
     android:textAppearance="@style/Regular"/> 
    <TextView 
     android:id="@+id/tv_text_comment2" 
     android:layout_width="wrap_content" 
     android:layout_marginTop="@dimen/space8" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tv_username2" 
     android:layout_alignLeft="@id/ratingBar2" 
     style="@style/Text14Reg"/> 
</RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="15dp" 
    android:paddingTop="262dp"> 
    <ImageView 
     android:id="@+id/iv_user3" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:background="@drawable/head4"/> 
    <RatingBar 
     android:id="@+id/ratingBar3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="@dimen/space16" 
     android:layout_marginBottom="@dimen/space8" 
     android:rating="5" 
     android:numStars="5" 
     android:isIndicator="true" 
     style="@style/RatingBar" 
     android:layout_toRightOf="@id/iv_user3"/> 
    <TextView 
     android:id="@+id/tv_username3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar3" 
     android:layout_alignLeft="@id/ratingBar3" 
     android:text="Kim, Vanaf €1.-" 
     android:textColor="@color/colorTextDark" 
     android:textSize="@dimen/h3" 
     android:textAppearance="@style/SemiBold"/> 
    <TextView 
     android:id="@+id/tv_date3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar3" 
     android:layout_marginLeft="@dimen/space8" 
     android:layout_toRightOf="@id/tv_username3" 
     android:layout_alignBaseline="@id/tv_username3" 
     android:text="Ik maak en verkoop kettingen" 
     android:textColor="@color/colorTextGrey" 
     android:textSize="12sp" 
     android:textAppearance="@style/Regular"/> 
    <TextView 
     android:id="@+id/tv_text_comment3" 
     android:layout_width="wrap_content" 
     android:layout_marginTop="@dimen/space8" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tv_username3" 
     android:layout_alignLeft="@id/ratingBar3" 
     style="@style/Text14Reg"/> 
</RelativeLayout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="15dp" 
    android:paddingTop="358dp"> 
    <ImageView 
     android:id="@+id/iv_user4" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:background="@drawable/head5"/> 
    <RatingBar 
     android:id="@+id/ratingBar4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="@dimen/space16" 
     android:layout_marginBottom="@dimen/space8" 
     android:rating="4" 
     android:numStars="5" 
     android:isIndicator="true" 
     style="@style/RatingBar" 
     android:layout_toRightOf="@id/iv_user4"/> 
    <TextView 
     android:id="@+id/tv_username4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar4" 
     android:layout_alignLeft="@id/ratingBar4" 
     android:text="Manon, n.o.t.k" 
     android:textColor="@color/colorTextDark" 
     android:textSize="@dimen/h3" 
     android:textAppearance="@style/SemiBold"/> 
    <TextView 
     android:id="@+id/tv_date4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/ratingBar4" 
     android:layout_marginLeft="@dimen/space8" 
     android:layout_toRightOf="@id/tv_username4" 
     android:layout_alignBaseline="@id/tv_username4" 
     android:text="Kledingontwerpster" 
     android:textColor="@color/colorTextGrey" 
     android:textSize="12sp" 
     android:textAppearance="@style/Regular"/> 
    <TextView 
     android:id="@+id/tv_text_comment4" 
     android:layout_width="wrap_content" 
     android:layout_marginTop="@dimen/space8" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tv_username4" 
     android:layout_alignLeft="@id/ratingBar4" 
     style="@style/Text14Reg"/> 
</RelativeLayout> 

Picture of how it needs to look like. On some way, its not working

回答

1

一個RecyclerView真的是最好的解決方案,爲您實現這個佈局。你不應該在佈局中使用那麼多RelativeLayouts(其中你沒有真正的父佈局,所以可能是你遇到問題的原因)。

相關問題