toRight of不起作用

时间:2018-07-16 11:10:18

标签: android android-layout

我想在“ Rate This Story”右边的一行中放入4星。对于Iam,在线性布局中使用toRightof命令,但不知道为什么它不起作用。当Iam尝试在图片底部的女孩图像的右侧放置文本时,也会发生相同的问题。

这是我的XML代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="3"
    android:background="@drawable/empty"
    tools:context=".story_activity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Story Name"
        android:textAlignment="center"
        android:textColor="#fff"
        android:layout_marginTop="5dp"
        android:textSize="20sp"
        android:textStyle="bold"></TextView>
       <!-- android:layout_marginLeft="140dp"-->/>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:weightSum="3"
        android:background="@drawable/story_des"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="15dp"
        android:alpha="0.8"
        android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/lion"/>

</LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1.2"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="This specification does not indicate the behavior, rendering or otherwise, of space characters other than those explicitly identified here as white space characters. For this reason, authors should use appropriate elements and styles to achieve visual formatting effects that involve white space, rather than space characters."
                android:padding="10dp"
                android:textColor="#fff"
                android:textSize="15sp"
                android:id="@+id/story_content"/>
            <TextView
                android:id="@+id/story_rate"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Rate This Story"
                android:padding="10dp"
                android:textSize="15sp"
                android:layout_marginTop="-10dp"
                android:textColor="#1e5aaa"
                android:textStyle="bold"/>

            <ImageView
                android:id="@+id/rate"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="-35dp"
                android:layout_marginLeft="130dp"
                android:src="@drawable/star"
                />
            <ImageView
                android:id="@+id/rate1"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_toRightOf="@+id/rate"

                android:src="@drawable/star"
                />
            <ImageView
                android:id="@+id/rate2"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_toRightOf="@+id/rate1"
                android:src="@drawable/star"
                />
            <ImageView
                android:id="@+id/rate3"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_toRightOf="@+id/rate2"
                android:src="@drawable/star"
                />

</LinearLayout>



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/line"/>
    <ImageView
        android:id="@+id/author_image"
        android:layout_width="80dp"
        android:layout_height="60dp"
        android:layout_below="@+id/user_line"
        android:layout_marginLeft="20dp"
        android:layout_marginBottom="20dp"
        android:src="@drawable/as" />


    <TextView
        android:id="@+id/author_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:layout_marginLeft="2dp"
        android:textSize="15dp"
        android:textColor="#fff"
        android:layout_toRightOf="@+id/author_image"
        android:fontFamily="century-gothic"
        android:layout_below="@+id/user_line"
        android:text="Author Title"
        />
    <TextView
        android:id="@+id/pub_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:layout_marginTop="3dp"
        android:layout_toRightOf="@+id/author_image"
        android:layout_below="@+id/author_title"
        android:layout_marginLeft="2dp"
        android:textSize="15dp"
        android:textColor="#fff"
        android:fontFamily="century-gothic"
        android:text="Pve sentences, cjajsxa "
        />

</LinearLayout>

</LinearLayout>
    </LinearLayout>

1 个答案:

答案 0 :(得分:0)

尝试将imageViews嵌入另一个具有linearLayout horizontal的{​​{1}}内,如下所示:

orientation

希望这会有所帮助