Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
listview中的android图像认为;“外部”;盒子_Android_Image_Listview_Row - Fatal编程技术网

listview中的android图像认为;“外部”;盒子

listview中的android图像认为;“外部”;盒子,android,image,listview,row,Android,Image,Listview,Row,我希望有一个ImageView,它是listview行项目的一部分,但同时显示在行内和行外。这可能吗?如果是,怎么做?非常感谢。。。 答案是“不完全”,至少不是以你的意思明确地说,但是你应该能够通过简单地为列表项使用背景图像,使图像看起来在行外,看起来列表的边缘与实际位置相隔几像素。然后,你可以将你想显示为溢出的元素对齐,并在你不想显示的元素上添加一些右边的填充/边距。我现在就可以使用了,我根本不必弄乱photoshop。我都是用androidxml完成的 方法是使用元素,而不是不使用填充来使用

我希望有一个ImageView,它是listview行项目的一部分,但同时显示在行内和行外。这可能吗?如果是,怎么做?非常感谢。。。

答案是“不完全”,至少不是以你的意思明确地说,但是你应该能够通过简单地为列表项使用背景图像,使图像看起来在行外,看起来列表的边缘与实际位置相隔几像素。然后,你可以将你想显示为溢出的元素对齐,并在你不想显示的元素上添加一些右边的填充/边距。

我现在就可以使用了,我根本不必弄乱photoshop。我都是用androidxml完成的

方法是使用
元素,而不是不使用填充来使用,如下所示:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="6dip" android:right="6dip" android:left="6dip">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners android:bottomRightRadius="2dip"
            android:bottomLeftRadius="2dip" android:topLeftRadius="6dip"
            android:topRightRadius="6dip" />
        <solid android:color="@color/list_view_outline" />

    </shape>
</item>
<item android:top="8dip" android:right="8dip" android:left="8dip">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners android:bottomRightRadius="2dip"
            android:bottomLeftRadius="2dip" android:topLeftRadius="6dip"
            android:topRightRadius="6dip" />
        <solid android:color="@android:color/white" />

        <stroke android:width="1dip" android:color="#BDBDBD" />
    </shape>
</item>

您应该能够在直接父视图上使用
android:clipChildren=“false”
android:clipToPadding=“false”
实现这一点,然后在所有祖先视图组上使用
android:clipChildren=“false”
,然后在图像视图上放置一个负边距;i、 e.
android:layout_marginLeft=“-10dp”


我花了一段时间才明白这些是如何工作的,尤其是
android:clipChildren=“false”
。Google说“定义子视图是否被限制在其边界内绘制”。关键点是,子视图的“边界”不是父视图组的边界,而是由其布局属性定义的视图边界,这就是为什么在祖先树上一直需要它。

Hi Ben,“行外”你是说绿色的图像吗???我不知道我是否清楚;该图像应该是用于该行的视图的子视图,并在其内部右上方对齐。如果对包含边框和空格的列表使用背景(可能是ninepatch),但右侧没有填充区域(也就是说,ninepatch的内容区域与右侧边框齐平),则会出现框外溢出。但因为它仍然是列表行的适当子行,溢出图像将针对每一行正确定向,而不考虑高度。我想可能有一种方法可以使用AbsoluteLayout实现这一点,我意识到这是不推荐的,但也许它会起作用???我目前正在考虑使用clipChildren或clipToPadding组合来让图像忽略行的边界。。。有什么想法吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/feed_list_row_content">
<ImageView android:id="@+id/author_image"
    android:layout_width="44dip" android:layout_height="44dip"
    android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
    android:src="@drawable/no_photo" android:layout_marginLeft="10dip"
    android:layout_marginTop="10dip" />
<TextView android:layout_width="wrap_content"
    android:layout_marginTop="10dip" android:layout_height="wrap_content"
    android:layout_toRightOf="@id/author_image" android:id="@+id/feed_message_content"
    android:layout_toLeftOf="@+id/action_button" />

<ImageView android:id="@id/action_button" android:src="@drawable/row_action"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_alignParentRight="true" android:layout_marginTop="20dip" />
if(position == 0)
        {
            holder.contentLayout.setBackgroundResource(R.drawable.top_row);
        } else if(position == posts.size() - 1)
        {
            holder.contentLayout.setBackgroundResource(R.drawable.bottom_row);
        } else {
            holder.contentLayout.setBackgroundResource(R.drawable.inner_row);
        }