Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java xml有时在某些android版本上不起作用_Java_Android_Xml_Layout_Android Relativelayout - Fatal编程技术网

Java xml有时在某些android版本上不起作用

Java xml有时在某些android版本上不起作用,java,android,xml,layout,android-relativelayout,Java,Android,Xml,Layout,Android Relativelayout,我一直在试着做一个布局。但在一些android版本上,比如api 25 你能看出我做错了什么吗?顺便说一句,由于某些原因,我的代码不适合这里。Android studio没有给我一个错误代码或什么。这使我的.apk很好。所有页面都正常工作,但这一页不正常 '<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android

我一直在试着做一个布局。但在一些android版本上,比如api 25

你能看出我做错了什么吗?顺便说一句,由于某些原因,我的代码不适合这里。Android studio没有给我一个错误代码或什么。这使我的.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>
'
A确实是实现此布局的最佳解决方案。你不应该在一个布局中使用那么多的RelativeLayout(你没有真正的父布局,这可能就是你遇到问题的原因)