Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将imageview置于中心位置_Android - Fatal编程技术网

Android 将imageview置于中心位置

Android 将imageview置于中心位置,android,Android,我想在我的listview中放置一个箭头 我正在尝试,但没有成功。以下是我的结果: 预期结果: 这是一个lisview。这是我的项目源代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:paddingBottom="4dp"

我想在我的listview中放置一个箭头

我正在尝试,但没有成功。以下是我的结果:

预期结果:

这是一个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>


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

箭头应该在外线布局中。将其放置在垂直线性布局中,但应是水平线性布局的一部分

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


非常感谢,它成功了。我还有一个问题,用户配置文件图片是焰火中的70x70 px。为了获得相同的结果,android dp系统中应该有什么。这取决于您。如果您希望70 px是xhdpi可绘制的分辨率,那么您应该按比例缩放另一个分辨率,并在布局中使用dpi。mdpi的系数为1,hdpi为1.5,xhdpi为2。所以1像素是mdpi的1倍,1.5像素是hdpi的1倍,2像素是XHDPI的1倍,最后一个问题:你知道为什么锚定和配置文件图片看起来模糊吗?很难说。你在什么设备上看到这些?我在Genymotion中使用Nexus 5