【问题标题】:Increasing a Youtube Thumbnail Size增加 Youtube 缩略图大小
【发布时间】:2013-12-02 21:49:35
【问题描述】:

我从以下教程中导入了源代码:

http://blog.blundell-apps.com/show-youtube-user-videos-in-a-listview/

https://github.com/blundell/YouTubeUserFeed/tree/master/res/layout

但我似乎无法增加缩略图的大小 - 我尝试将我的 XML 中的 userVideoThumbImageView 更改为:

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_width="80dip"
    android:layout_height="80dip"


    but it only seems to increase the size of the black space around the thumbnail. 

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="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal" >

    <com.blundell.tut.ui.widget.UrlImageView
        android:id="@+id/userVideoThumbImageView"
        android:layout_width="80dip"
        android:layout_height="80dip"
        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:text="Video Title Not Found" />

</LinearLayout>

屏幕截图:

【问题讨论】:

    标签: java android xml youtube android-ui


    【解决方案1】:

    该教程在实现异步任务方面并不是那么好。虽然可运行对象工作正常,但在 Android 中,AsyncTask 将提供更多控制。

    现在,对于您遇到的问题,我相信 youtube 提供了各种尺寸的缩略图,您似乎在拉小一个。使用更大的会有所帮助,但会更慢。

    在 GetYouTubeUserVideosTask 类中,您会找到代码行

    String thumbUrl = jsonObject.getJSONObject("thumbnail").getString("sqDefault");

    如果它从接收的 JSON 中提取标准质量图像,您应该使用高质量图像。这可以通过更改为

    来实现

    String thumbUrl = jsonObject.getJSONObject("thumbnail").getString("hqDefault");

    您可以通过查看正在使用的 url 随时执行示例请求并查看数据,返回部分看起来像这样:

    "thumbnail":{"sqDefault":"https://i.ytimg.com/vi/NnL0QOtK-o8/default.jpg","hqDefault":"https://i.ytimg.com/vi/NnL0QOtK-o8/hqdefault.jpg"}

    这样你就知道你有多种选择。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-05
    • 2017-04-22
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 1970-01-01
    相关资源
    最近更新 更多