我正在尝试从互联网上加载图像并将其放在ImageView
中,但我想将屏幕宽度用作图像的宽度并保持纵横比。我已经在stackoverflow上尝试了所有解决方案,但它没有帮助。我想因为我之后从互联网上加载图片并将其放入ImageView
。
这是xml文件。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".ViewPhoto"
android:background="@color/darkgrey"
android:id="@+id/layout"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:id="@+id/title"
android:background="@color/Black"
android:typeface="sans"
android:textColor="@color/White"
/>
<ImageView
??
/>
<ListView
android:id="@+id/comments"
android:layout_below="@+id/photo"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:divider="#b5b5b5"
android:dividerHeight="2dp"
/>
</RelativeLayout>
答案 0 :(得分:1)
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@id/title"
/>
以这种方式尝试
答案 1 :(得分:0)
尝试在android:scaleType="centerCrop"
内使用ImageView
。