简体   繁体   English

Android网格根据屏幕密度查看图像大小

[英]Android Grid View image size according to screen density

The grid view of my application has 4 rows and 4 columns. 我的应用程序的网格视图有4行4列。 I want this to fill half screen ,irrespective of the screen size of the device. 无论设备的屏幕尺寸如何,我希望这能填充半屏。 How can i set the image view size accordingly 如何相应地设置图像视图大小

在dp中定义图像视图的大小,它将根据屏幕密度设置大小。

The easiest way would be to set the size of the GridView in dip (device-independent pixels). 最简单的方法是将dipView的大小设置为dip(与设备无关的像素)。 You can do this via your XML layout file, explicitly or with the help of the visual editor. 您可以通过XML布局文件,显式地或在可视化编辑器的帮助下完成此操作。 As device-independent pixels are essentially percentiles, the Android platform will handle resizing for you based on the size and density of the device displaying. 由于与设备无关的像素基本上是百分位数,因此Android平台将根据设备显示的大小和密度为您调整大小。 In order words, a value of android:layout_width="50dip" will look the same on any device. 换句话说,android:layout_width =“50dip”的值在任何设备上看起来都是一样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM