Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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应用程序-使视图仅占父视图的一部分_Android_Android Layout_Listview_Android View - Fatal编程技术网

android应用程序-使视图仅占父视图的一部分

android应用程序-使视图仅占父视图的一部分,android,android-layout,listview,android-view,Android,Android Layout,Listview,Android View,我的应用程序上有一个背景图像,我希望我的listview是一个覆盖背景图像的窗口。有点像图片中有白色滤镜的表单: 我目前有一个用xml定义的listview,其中包含: android:layout_width="fill_parent" android:layout_height="fill_parent" 和半透明的颜色作为背景。这很好,但它占据了整个屏幕,因为它填充了父级的宽度和高度。使其略小于父对象的尺寸的最佳方法是什么,以便表示(填充父对象-某些相对值)高度和宽度 将FrameL

我的应用程序上有一个背景图像,我希望我的listview是一个覆盖背景图像的窗口。有点像图片中有白色滤镜的表单:

我目前有一个用xml定义的listview,其中包含:

android:layout_width="fill_parent" 
android:layout_height="fill_parent"

和半透明的颜色作为背景。这很好,但它占据了整个屏幕,因为它填充了父级的宽度和高度。使其略小于父对象的尺寸的最佳方法是什么,以便表示(填充父对象-某些相对值)高度和宽度

将FrameLayout用作父级,然后添加ListView并设置宽度和高度以包装内容。现在,它应该“浮动”在FrameLayout内的其他视图之上。您可以使用填充和边距设置其位置。

在布局中使用边距,使其相对于父布局和其他子布局更小