Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
匹配父项,但未按预期填充-Android/XML_Android_Xml_Thumbnails_Android Ui_Android Xml - Fatal编程技术网

匹配父项,但未按预期填充-Android/XML

匹配父项,但未按预期填充-Android/XML,android,xml,thumbnails,android-ui,android-xml,Android,Xml,Thumbnails,Android Ui,Android Xml,我在listView中有一个YoutubeThumbnail/ImageView,我希望填充/拉伸到屏幕边缘: <com.example.project.ui.widget.VideosListView android:id="@+id/videosListView" android:adjustViewBounds="true" android:scaleType="fitXY"

我在listView中有一个YoutubeThumbnail/ImageView,我希望填充/拉伸到屏幕边缘:

        <com.example.project.ui.widget.VideosListView
            android:id="@+id/videosListView"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        </LinearLayout>
编辑:

编辑后的屏幕截图:

如果要扩展ImageView,请尝试应用此选项:

android:scaleType="fitXY"
或者用Java代码

imageView.setScaleType(ScaleType.FIT_XY);
2) 应用上述代码,如:

<com.example.project.ui.widget.UrlImageView
        android:id="@+id/userVideoThumbImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:adjustViewBounds="false"
        android:background="@android:color/black"
        android:clickable="false"
        android:contentDescription="YouTube video thumbnail"
        android:focusable="false"
        android:scaleType="fitXY"
        android:focusableInTouchMode="false"
        android:gravity="center"
        android:src="@drawable/ic_launcher" />


既然URLIGEVIEW从internet获取图像,那么在获取图像之前,它如何知道其大小

在显示listView项之前,必须确定其视图的高度

另外,android:adjustViewBounds=“true”与android:scaleType=“fitXY”也不能很好地结合,因为adjustViewBounds表示它将保持纵横比(link),而fitXY表示不会(link)。你需要决定什么对你来说是重要的——拉伸图像还是保持纵横比。这个问题无处不在,不仅仅存在于android上

由于您似乎是ListView的新手,我建议您观看


另外,顺便说一句,我在截图上看到的不是一个好的android应用程序设计。请退房。如果你的应用程序没有遵循谷歌的指导原则,那么即使它变得流行,它在play store中获得功能的可能性也很低。

这些设备的API版本是什么?在版本18(=4.3)之前,RelativeLayout中存在一个度量错误,他们都在使用4.2.2或更低版本(知道解决方法/修复可能是什么吗?)不应该在XML中的哪个点使用
match\u parent
而不是
fill\u parent
?(无论我在哪里使用fill\u parent?@user3113035您是否尝试过下面的代码?@user3113035尝试将android:adjustViewBounds=“true”更改为android:adjustViewBounds=“false”并不完全解决我的问题,但我发现了一些有用的东西!增加图像的大小比保持高宽比重要得多——找到一种方法可以解决我目前的主要问题(我将根据android指南研究重新格式化,但此时我真的需要找到一种使图像更大的方法)我用来构建本文一部分的文章的作者似乎认为scaleType=fitXY应该有效——但它似乎不起作用(看看本文中的第一条评论),所以你不关心拉伸?如果是这样,请使用adjustViewBounds=“false”、scaleType=“fitXY”并移除重力。看,我不知道这个名为“URLMageView”的自定义视图是如何工作的,但如果它按照我的想法工作(从imageView扩展),它应该可以正常工作。如果没有,您可以简单地将图像文件下载到缓存中,根据需要缩小它们的比例,并使用ImageView上的位图。如果它们已经是小图像(取决于服务器),您可以使用Google的Volley的“NetworkImageView”类。你也可以做一个测试,看看你的自定义ImageView是否正常-只需使用ImageView并用src将其设置为指向你应用程序中的可绘制图形。我更新了我的源代码和上面的屏幕截图(缩略图仍然很小-现在偏离中心)
private VideosListView listView;


listView = (VideosListView) findViewById(R.id.videosListView);
        listView.setOnVideoClickListener(this);


            private void populateListWithVideos(Message msg) {
        Library lib = (Library) msg.getData().get(
                GetYouTubeUserVideosTask.LIBRARY);
        listView.setVideos(lib.getVideos());

    }
<?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:orientation="vertical" >

    <com.idg.omv.ui.widget.UrlImageView
        android:id="@+id/userVideoThumbImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:adjustViewBounds="false"
        android:background="@android:color/black"
        android:clickable="false"
        android:contentDescription="YouTube video thumbnail"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <View
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:visibility="invisible" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/userVideoTitleTextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="5dip"
            android:text="Video Title Not Found"
            android:textColor="@android:color/black"
            android:textSize="20sp" />

        <Button
            android:id="@+id/fav_up_btn1"
            android:layout_width="27dp"
            android:layout_height="27dp"
            android:layout_alignParentRight="true"
            android:background="@drawable/fav_up_btn1"
            android:clickable="false"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:gravity="right"
            android:paddingRight="5dp"
            android:paddingTop="5dp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/userVideouploaderTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="5dip"
            android:textColor="@color/verylightgrey"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/userVideoviewsTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/userVideouploaderTextView"
            android:textColor="@android:color/black"
            android:textSize="16sp" />
    </RelativeLayout>

</LinearLayout>
android:scaleType="fitXY"
imageView.setScaleType(ScaleType.FIT_XY);
<com.example.project.ui.widget.UrlImageView
        android:id="@+id/userVideoThumbImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:adjustViewBounds="false"
        android:background="@android:color/black"
        android:clickable="false"
        android:contentDescription="YouTube video thumbnail"
        android:focusable="false"
        android:scaleType="fitXY"
        android:focusableInTouchMode="false"
        android:gravity="center"
        android:src="@drawable/ic_launcher" />
android:adjustViewBounds="true"
android:adjustViewBounds="false"