NetworkImageView 占据屏幕的整个宽度
NetworkImageView to occupy full width of screen
我正在使用 com.android.volley.toolbox.NetworkImageView。
图片来自 url。
我想显示图像,使其宽度占据屏幕的整个宽度而不是高度,因为图像下方有一个标题,它是一个 Textview。
这是activity的xml
<?xml version="1.0" encoding="utf-8"?>
<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:background="@color/black"
tools:context=".MainActivity" >
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
这是项目 xml。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/button_register" />
<TextView
android:id="@+id/caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/photo_image"
android:layout_marginLeft="15dp"
android:text="Check"
android:textColor="@color/white" />
</RelativeLayout>
从后端看,图像大小为 300 X 200 像素。
如何设置 imageview 使其可以占据屏幕的整个宽度。
有人可以帮忙吗?
NetworkImageView
extends ImageView
所以你应该能够使用所有适用于 ImageView
.
的东西
因此,如果您希望您的图像占据整个宽度并调整其高度以保持其纵横比(至少这是我理解的您想要做的),请使用 adjustViewBounds
属性
您的 xml 将如下所示:
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/button_register"
<!-- add adjustViewBounds -->
android:adjustViewBounds="true" />
我正在使用 com.android.volley.toolbox.NetworkImageView。 图片来自 url。 我想显示图像,使其宽度占据屏幕的整个宽度而不是高度,因为图像下方有一个标题,它是一个 Textview。
这是activity的xml
<?xml version="1.0" encoding="utf-8"?>
<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:background="@color/black"
tools:context=".MainActivity" >
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
这是项目 xml。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/button_register" />
<TextView
android:id="@+id/caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/photo_image"
android:layout_marginLeft="15dp"
android:text="Check"
android:textColor="@color/white" />
</RelativeLayout>
从后端看,图像大小为 300 X 200 像素。 如何设置 imageview 使其可以占据屏幕的整个宽度。 有人可以帮忙吗?
NetworkImageView
extends ImageView
所以你应该能够使用所有适用于 ImageView
.
因此,如果您希望您的图像占据整个宽度并调整其高度以保持其纵横比(至少这是我理解的您想要做的),请使用 adjustViewBounds
属性
您的 xml 将如下所示:
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp"
android:src="@drawable/button_register"
<!-- add adjustViewBounds -->
android:adjustViewBounds="true" />