LinearLayout中的垂直对齐方式

3

我有一个线性布局,就像这样:

enter image description here

你可以看到我在左侧有一个箭头。它应该指向 Message,但你看它位于 Message 的上方。如何将它对齐,像这样:

enter image description here

我的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:paddingBottom="4dp"
              android:paddingTop="4dp"
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

    <ImageView
            android:id="@+id/image"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:src="@drawable/defaultprofile"/>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:paddingLeft="4dp"
        android:paddingRight="4dp" >

        <TextView
            android:id="@+id/tweet"
            style="@android:style/TextAppearance.Medium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="#0A0A14" 
            android:layout_marginLeft="8dp"
            android:textSize="15sp"
            android:text="Tolgay Toklar"
            android:fontFamily="sans-serif-condensed"
            />
    <ImageView
            android:id="@+id/ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/sagokgri"/>
        <TextView
            android:id="@+id/bio"
            style="@android:style/TextAppearance.Small"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="#474747" 
            android:layout_marginLeft="8dp"
            android:maxLines="3"
            android:text="Message"
            android:textSize="11sp"
            android:layout_marginTop="0dp"/>



    </LinearLayout>
    <ImageView
 android:id="@+id/image1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_gravity="right|center_vertical"

 android:src="@drawable/anchor" />
</LinearLayout>
1个回答

6

移除那个 ImageView 并使用它像 drawableLeft 一样,就像这样:

<TextView
    ...
    android:text="Message"
    android:drawableLeft="@drawable/sagokgri"
    .../>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接