Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的应用程序的网格视图有 4 行和 4 列。无论设备的屏幕尺寸如何,我都希望它填满半屏。如何相应地设置图像视图大小
在dp中定义图像视图的大小,它将根据屏幕密度设置大小。
最简单的方法是在 dip 中设置 GridView 的大小(与设备无关的像素)。您可以通过您的 XML 布局文件,显式地或借助可视化编辑器来执行此操作。由于与设备无关的像素本质上是百分位数,Android 平台将根据设备显示的大小和密度为您处理大小调整。换句话说,android:layout_width="50dip" 的值在任何设备上看起来都是一样的。