简体   繁体   English

如何使图像适合Android应用程序上的所有设备

[英]How can I make images fit every device on android application

I am inserting buttons and images which should touch the borders horizontally of the android device's width, but they are not a result there is little space left on both the sides of the button and images. 我正在插入按钮和图像,它们应该水平接触android设备宽度的边界,但这并不是结果,按钮和图像的两侧都几乎没有剩余空间。 And when I test the app on a larger dimension device the images and button appear pretty small comparatively. 当我在较大尺寸的设备上测试该应用程序时,图像和按钮相对较小。 What should I do? 我该怎么办?

These links will help you to create application for multiple screens : 这些链接将帮助您为多个屏幕创建应用程序:

http://developer.android.com/training/multiscreen/screensizes.html http://developer.android.com/training/multiscreen/screensizes.html

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

These are android's official documents on implementing support for multiple screen sizes. 这些是android的有关实现对多种屏幕尺寸的支持的官方文档。

<supports-screens android:smallScreens="true" 
          android:normalScreens="true" 
          android:largeScreens="true"
          android:xlargeScreens="true"
          android:anyDensity="true" />

Add this to your manifest file of your application. 将此添加到您的应用程序的清单文件。

there is little space left on both the sides of the button and images 按钮和图像两边的空间很小

Try changing the margin and padding of your UI components. 尝试更改UI组件的边距和填充。

And when I test the app on a larger dimension device the images and button appear pretty small comparatively. 当我在较大尺寸的设备上测试该应用程序时,图像和按钮相对较小。

Android documentation provides pretty detailed information on what size image should be used for various screen sizes. Android文档提供了有关各种屏幕尺寸应使用哪种尺寸图像的相当详细的信息。 You might want to read that. 您可能想要阅读。

In your XML file you can use android:scaleType . 在您的XML文件中,您可以使用android:scaleType See documentation for scaleType . 有关scaleType,请参见文档。

scaleType is a bit difficult to understand with the provided description unless you use each scale type and see its effects for yourself. 除非您使用每种比例类型并亲自查看其效果,否则使用所提供的说明很难理解scaleType。

Programmatically you can do something like this but it would very much depend on your particular use case requirement. 您可以通过编程方式执行此类操作,但这在很大程度上取决于您的特定用例需求。

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

相关问题 确保Android布局适合所有设备 - Make sure android layout will fit on every device 如何在Android设备上的特定日期显示图片 - how can I make images show on a specific date on android device 如何确保我的应用程序与每台Android设备兼容,并将视图缩放以适​​合不同的屏幕尺寸? - How can I ensure that my app is compatible with every Android device and will scale views to fit different screen dimensions? 如何检测室内是否装有Google Fit的android设备? - How can I detect if an android device indoor with Google Fit? 如何使gif图像适合Android上的WebView - How to make gif images to fit WebView on Android Android,如何将BLE设备配对设备(已绑定) - Android, How can I make BLE device to paired device (bonded) 如何使 Android RecyclerView 响应最初适合屏幕? - How can I make the Android RecyclerView responsive to fit the screen initially? 如何在Android Studio中为每个设备设置标准布局 - How can I set a standard layout for every device in android studio 应用程序不适合android虚拟设备 - application not fit to the android virtual device 我可以将android应用程序的背景设置为一组图像吗? - Can I make the background of the android application as group of images?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM