如何在XML的LinearLayout中放置TextView?

时间:2018-10-17 02:07:54

标签: xml android-layout android-linearlayout

我正在为我的exoplayer制作视频播放器UI。我正在打印TextViews以显示可用于视频的质量。我无法将TextView放在彼此下方。他们自动将它们彼此相邻放置。如何将它们放置在彼此下方?

我得到和不想得到的:

enter image description here

我想要什么:

enter image description here

我的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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"
    tools:context=".MainActivity">

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/player_screen"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:use_controller="false" />

    <LinearLayout
        android:id="@+id/root"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/middle"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="horizontal"></LinearLayout>

        <LinearLayout
            android:id="@+id/options_container"
            android:layout_width="fill_parent"
            android:layout_height="400dp"
            android:layout_weight="1"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/options_container02"
                android:layout_width="100dp"
                android:layout_height="40dp"
                android:textColor="#000000"
                android:textSize="20dp"
                android:gravity="center"
                android:orientation="horizontal"
                android:text="2160p">
                <requestFocus />
            </TextView>

            <TextView
                android:layout_width="100dp"
                android:layout_height="40dp"
                android:layout_below="@id/options_container02"
                android:gravity="center"
                android:orientation="horizontal"
                android:text="1080p"
                android:textColor="#000000"
                android:textSize="20dp">

                <requestFocus />
            </TextView>
        </LinearLayout>


        <LinearLayout
            android:id="@+id/seek_bar_panel"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:background="#cfcfd1"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/text_view_current"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp"
                android:text="00:00:00"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#FFF" />

            <SeekBar
                android:id="@+id/seek_bar"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <TextView
                android:id="@+id/text_view_total"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="20dp"
                android:paddingTop="10dp"
                android:text="00:00:00"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#FFF" />
            <ImageButton
                android:id="@+id/button_setting"
                android:onClick="button_setting_click"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:paddingRight="20dp"
                android:paddingTop="10dp"
                android:src="@drawable/setting_img"/>
        </LinearLayout>
    </LinearLayout>
</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

options_container的方向应垂直