Android layout ImageView未在线性布局中显示全尺寸
为了好玩,我正在开发Udacity流行电影应用程序。我正在点击GridView中的电影图像,进入细节视图,我希望在上面显示背景图像,标题在下面,概述在下面。所有在线性布局与重力的一切在顶部 以下是在ImageView中设置图像的代码:Android layout ImageView未在线性布局中显示全尺寸,android-layout,Android Layout,为了好玩,我正在开发Udacity流行电影应用程序。我正在点击GridView中的电影图像,进入细节视图,我希望在上面显示背景图像,标题在下面,概述在下面。所有在线性布局与重力的一切在顶部 以下是在ImageView中设置图像的代码: ImageView imageView = (ImageView) findViewById(R.id.imageView); Picasso.with(this).load("http://image.tmdb.org/t/p/w500/" + mo
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Picasso.with(this).load("http://image.tmdb.org/t/p/w500/" + movie.backDrop).into(imageView);
以下是详细布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:layout_gravity="top"
android:orientation="vertical"
tools:context="com.ferr3t.don.gurumovies.MovieDetail">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/text_view_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/text_view_description" />
</LinearLayout>
我不知道为什么图像居中而小,我想让它填满屏幕的宽度。任何帮助都将不胜感激。请在xml Imageview属性中尝试此功能
android:scaleType="fitXY"
这会在屏幕上拉伸图像,但高度保持不变。请使用centralcrop代表fitXY CenterCrop在屏幕上拉伸图像,然后将其裁剪为与fitXY相同的高度。还有别的想法吗?到目前为止,我能让它工作的唯一方法是设置布局_height=“200dp”,但当它进入横向模式时,当然会把事情搞砸。