从上到下移动textview

时间:2015-06-19 08:46:24

标签: android xml android-layout layout

example picture

在上图中,我想在图像和其他textview下移动包含bill microsoft的textview。我怎么能这样做?

我现在写了这个布局。

AND

2 个答案:

答案 0 :(得分:1)

请使用此

<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/card_tracks"
    android:layout_width="match_parent"
    android:layout_height="180dp"
    android:layout_gravity="center"
    android:layout_margin="16dp"
    android:elevation="7dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/main_ll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical">

            <ImageView
                android:id="@+id/speaker_image"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_margin="10dp"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop"
                android:src="@drawable/icon" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical"
                android:padding="10dp">

                <TextView
                    android:id="@+id/speaker_name"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight="0.5"
                    android:gravity="center_vertical"
                    android:text="placeholder_speaker_name"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="#000000"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/speaker_designation"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight="0.5"
                    android:gravity="top"
                    android:text="placeholder_speaker_designation"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="#000000"
                    android:textStyle="bold" />

            </LinearLayout>

        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/speaker_bio"
                android:layout_width="326dp"
                android:layout_height="64dp"
                android:layout_margin="10dp"
                android:text="placeholder_speaker_bio"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="#000000" />
        </RelativeLayout>
    </LinearLayout>
</android.support.v7.widget.CardView>

答案 1 :(得分:0)

您只需添加:

android:orientation="vertical"

到第一个LinearLayout,因此可以在ImageView下面绘制TextView。