【发布时间】:2013-12-05 00:17:07
【问题描述】:
我试图让我的缩略图 (userVideoThumbImageView) 扩展到屏幕边缘,但它似乎没有这样做。我将宽度设置为 fill_parent 所以我不确定它为什么不这样做:
截图:
http://www.flickr.com/photos/110503723@N07/11207214295
list_item_user_video.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<com.blundell.tut.ui.widget.UrlImageView
android:id="@+id/userVideoThumbImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:contentDescription="YouTube video thumbnail"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/userVideoTitleTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="Video Title Not Found" />
</LinearLayout>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:orientation="vertical" >
<com.blundell.tut.ui.widget.VideosListView
android:id="@+id/videosListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_alignParentBottom="true" >
<HorizontalScrollView
android:id="@+id/groupScrollView"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
</HorizontalScrollView>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/scroll_lt_arrow" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/scroll_rt_arrow" />
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
JAVA:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// If convertView wasn't null it means we have already set it to our list_item_user_video so no need to do it again
if(convertView == null){
// This is the layout we are using for each row in our list
// anything you declare in this layout can then be referenced below
convertView = mInflater.inflate(R.layout.list_item_user_video, parent, false); resolved the issue!
}
// We are using a custom imageview so that we can load images using urls
// For further explanation see: http://blog.blundell-apps.com/imageview-with-loading-spinner/
UrlImageView thumb = (UrlImageView) convertView.findViewById(R.id.userVideoThumbImageView);
TextView title = (TextView) convertView.findViewById(R.id.userVideoTitleTextView);
// Get a single video from our list
final Video video = videos.get(position);
// Set the image for the list item
thumb.setImageDrawable(video.getThumbUrl());
// Set the title for the list item
title.setText(video.getTitle());
return convertView;
}
【问题讨论】:
-
你的意思是它不会拉伸屏幕的高度吗?
-
不 - 我的意思是它不会拉伸宽度:flickr.com/photos/110503723@N07/11195356793
-
尝试将 viewpager 更改为 match_parent?
-
我做了 - 还是一样(如屏幕截图所示)
-
注意 - 我不是想改变 viewpager - 我是想改变 userVideoThumbImageView
标签: android xml android-ui android-xml