同一行的文本视图

Text view on the same line

我试图将两个 textView 放在同一行上,但我遇到了一些问题。这是现在的观点:

我想将发布日期放在该行的左侧,将国家/地区放在同一行的右侧。我试图将该块置于线性布局中,但一切都在屏幕的左上角。这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    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="#1f1f1f"
    android:id="@+id/detail_activity"
    tools:context="com.lab.movietime.View.Activity.Activity.Activity.DetailActivity">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/_16sdp"
        android:paddingLeft="@dimen/_16sdp"
        android:paddingRight="@dimen/_16sdp"
        tools:context="com.lab.movietime.View.Activity.Activity.Activity.DetailActivity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/ll1"
            android:orientation="vertical">
            <ImageView
                android:layout_width="@dimen/_80sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_marginTop="@dimen/_10sdp"
                android:background="@drawable/logoss"
                android:layout_gravity="center"/>

        </LinearLayout>

        <LinearLayout
            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:layout_below="@id/ll1"
            android:layout_marginTop="@dimen/_10sdp"
            android:id="@+id/youtubePlayer"
            android:orientation="vertical" >

            <com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
                android:id="@+id/youtube_player_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:showFullScreenButton="false" />
        </LinearLayout>


        <LinearLayout
            android:id="@+id/container"
            android:layout_below="@id/youtubePlayer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/_9sdp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/posterImg"
                android:layout_width="0dp"
                android:layout_height="@dimen/_180sdp"
                android:layout_weight="1"
                android:scaleType="centerCrop"
                android:background="@android:color/darker_gray"/>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/_11sdp"
                android:layout_marginTop="@dimen/_3sdp"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:textColor="#ffffff"
                    android:text="MovieTitle"
                    android:id="@+id/movieTitle"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                    android:textStyle="bold"/>

                <TextView
                    android:id="@+id/genresTextView"
                    android:layout_width="wrap_content"
                    android:textColor="#ffffff"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    tools:text="Action, Adventure, Science Fiction, Thriller"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:text="Rating"
                    android:textColor="#ffffff"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                    android:textStyle="bold"/>

                <RatingBar
                    android:id="@+id/listitemrating"
                    android:layout_width="236dp"
                    android:layout_height="43dp"
                    android:numStars="5"
                    android:scaleX="0.5"
                    android:scaleY="0.5"
                    android:theme="@style/RatingBar"
                    android:transformPivotX="@dimen/_10sdp"
                    android:transformPivotY="0dp" />

                <Button
                    android:id="@+id/favButton"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#ffffff"
                    android:background="@drawable/layout_rounded_corner"
                    android:text="Add to watchlist"/>


            </LinearLayout>
        </LinearLayout>

        <!-- BEGINNING BLOCK -->

        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/releaseDateHeader"
            android:layout_below="@id/container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Release Date"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/releaseDateHeader"
            android:id="@+id/releaseDateTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>

        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/countryHeader"
            android:layout_below="@id/releaseDateHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Country"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/countryHeader"
            android:id="@+id/countryTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>

        <!-- END OF BLOCK -->


        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/overviewHeader"
            android:layout_below="@id/countryTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Overview"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/overviewHeader"
            android:id="@+id/overviewTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:background="@layout/rounded_border_textview"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="8dp"
            tools:text="Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond."/>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>

    </RelativeLayout>
</ScrollView>

我要插入的块是在评论中。这是我创建线性布局的结果:

将这些项目放在 Relativelayout 中并将它们设置为 alignpatentend

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/container"

        >

        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/releaseDateHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Release Date"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/releaseDateHeader"
            android:id="@+id/releaseDateTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>

        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/countryHeader"
            android:layout_alignParentEnd="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Country"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/countryHeader"
            android:id="@+id/countryTextView"
            android:layout_width="wrap_content"
            android:layout_alignParentEnd="true"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>

        <!-- END OF BLOCK -->


        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/overviewHeader"
            android:layout_below="@id/countryTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Overview"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/overviewHeader"
            android:id="@+id/overviewTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:background="@layout/rounded_border_textview"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="8dp"
            tools:text="Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond."/>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>
    </RelativeLayout>

检查这个:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    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="#1f1f1f"
    android:id="@+id/detail_activity"
    tools:context="com.lab.movietime.View.Activity.Activity.Activity.DetailActivity">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/_16sdp"
        android:paddingLeft="@dimen/_16sdp"
        android:paddingRight="@dimen/_16sdp"
        tools:context="com.lab.movietime.View.Activity.Activity.Activity.DetailActivity">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/ll1"
            android:orientation="vertical">
            <ImageView
                android:layout_width="@dimen/_80sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_marginTop="@dimen/_10sdp"
                android:background="@drawable/logoss"
                android:layout_gravity="center"/>

        </LinearLayout>

        <LinearLayout
            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:layout_below="@id/ll1"
            android:layout_marginTop="@dimen/_10sdp"
            android:id="@+id/youtubePlayer"
            android:orientation="vertical" >

            <com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
                android:id="@+id/youtube_player_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:showFullScreenButton="false" />
        </LinearLayout>


        <LinearLayout
            android:id="@+id/container"
            android:layout_below="@id/youtubePlayer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/_9sdp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/posterImg"
                android:layout_width="0dp"
                android:layout_height="@dimen/_180sdp"
                android:layout_weight="1"
                android:scaleType="centerCrop"
                android:background="@android:color/darker_gray"/>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/_11sdp"
                android:layout_marginTop="@dimen/_3sdp"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:textColor="#ffffff"
                    android:text="MovieTitle"
                    android:id="@+id/movieTitle"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                    android:textStyle="bold"/>

                <TextView
                    android:id="@+id/genresTextView"
                    android:layout_width="wrap_content"
                    android:textColor="#ffffff"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    tools:text="Action, Adventure, Science Fiction, Thriller"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"
                    android:text="Rating"
                    android:textColor="#ffffff"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
                    android:textStyle="bold"/>

                <RatingBar
                    android:id="@+id/listitemrating"
                    android:layout_width="236dp"
                    android:layout_height="43dp"
                    android:numStars="5"
                    android:scaleX="0.5"
                    android:scaleY="0.5"
                    android:theme="@style/RatingBar"
                    android:transformPivotX="@dimen/_10sdp"
                    android:transformPivotY="0dp" />

                <Button
                    android:id="@+id/favButton"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#ffffff"
                    android:background="@drawable/layout_rounded_corner"
                    android:text="Add to watchlist"/>


            </LinearLayout>
        </LinearLayout>

        <!-- BEGINNING BLOCK -->

        <LinearLayout
            android:id="@+id/linear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/container"
            android:weightSum="2">


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            >
        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/releaseDateHeader"
            android:layout_below="@id/container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Release Date"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/releaseDateHeader"
            android:id="@+id/releaseDateTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>

        </RelativeLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_weight="1">
        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/countryHeader"
            android:layout_below="@id/releaseDateHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Country"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/countryHeader"
            android:id="@+id/countryTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            tools:text="ff"/>
    </RelativeLayout>
        </LinearLayout>
        <!-- END OF BLOCK -->


        <TextView
            android:layout_marginTop="16dp"
            android:id="@+id/overviewHeader"
            android:layout_below="@id/linear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:textColor="#ffffff"
            android:text="Overview"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
            android:textStyle="bold"/>

        <TextView
            android:layout_below="@id/overviewHeader"
            android:id="@+id/overviewTextView"
            android:layout_width="wrap_content"
            android:ellipsize="end"
            android:textColor="#ffffff"
            android:background="@layout/rounded_border_textview"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="8dp"
            tools:text="Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond. Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond."/>

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>

    </RelativeLayout>
</ScrollView>

我把 block 放在 LinearLayout 里面,里面有两个 RelativeLayout 居中。
我没有清除这 4 个 TextView 中不必要的参数,我将其命名为 LinearLayout "linear",但这些只是外观上的更改。