Android 同一行上的文本视图

Android 同一行上的文本视图,android,xml,android-layout,textview,Android,Xml,Android Layout,Textview,我试图将两个textView放在同一行上,但我遇到了一些问题。这是目前的观点: 我想把发布日期放在这行的左边,把国家放在同一行的右边。我试着把那个块放在一个线性布局中,但是所有的东西都在屏幕的左上角。这是我的代码: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="h

我试图将两个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中,并将其设置为AlignLayout

 <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>

我把
放在
线性布局
里面,里面有两个
相对线

我没有清除这4个
TextView
中不必要的参数,我将
LinearLayout
命名为“linear”,但这些只是表面上的更改