将imageview放置到中心

时间:2014-09-28 14:54:15

标签: android

我想在我的列表视图中放置一个箭头。

我正在尝试但是,我没有这样做。这是我的结果:

enter image description here

预期结果:

enter image description here

这是一个lisview。这是我的项目源代码:

<?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/twitter"/>

    <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:fontFamily="sans-serif-condensed"
            />

        <TextView
            android:id="@+id/handle"
            style="@android:style/TextAppearance.Small"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form"
            android:textColor="#474747" 
            android:layout_marginLeft="8dp"
            android:textSize="10sp"
            android:layout_marginTop="4dp"/>

            <ImageView
                android:id="@+id/image1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:src="@drawable/anchor" />

    </LinearLayout>
</LinearLayout>

如何将箭头置于中心?我还有一个问题。为什么箭头在上面的图像看起来很模糊?

1 个答案:

答案 0 :(得分:0)

箭头应位于外部LinearLayout中。您将它放在垂直LinearLayout中,但应该是水平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" />