我有一个 1080x1920px
图像,我想将其用作应用程序中的背景图像。
在我的 Galaxy S6
上工作正常,但当我降低到较小的屏幕尺寸(即 S4)时,我收到此消息:
W/OpenGLRenderer﹕ Bitmap too large to be uploaded into a texture (3240x5760, max=4096x4096)
此外图像根本不显示。
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}"
android:background="@drawable/bg">
<EditText android:id="@+id/username_textfield"
android:layout_width="270dp"
android:layout_height="40dp"
android:hint="Username"
android:textColorHint="#ffffff"
android:textColor="#ffffff"
android:ellipsize="start"
android:gravity="center_horizontal"
android:singleLine="true"
android:layout_marginTop="50dp"
android:layout_marginLeft="60dp"
android:background="@drawable/textfield_bg"/>
<EditText android:id="@+id/password_textfield"
android:layout_width="270dp"
android:layout_height="40dp"
android:hint="Password"
android:textColorHint="#ffffff"
android:textColor="#ffffff"
android:ellipsize="start"
android:gravity="center_horizontal"
android:singleLine="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="60dp"
android:background="@drawable/textfield_bg"/>
除了 onCreate 之外,我的 MainActivity 是空的。 我已经阅读了有关此问题的其他帖子,但没有一个为我提供任何真正的解决方案。
最佳答案
您应该创建名为nodpi的可绘制文件夹。 nodpi 应用程序适用于所有手机。
A drawable in res/drawable-nodpi/ is valid for any screen density .if there is another drawable with the same base name in a density-specific directory, and the device running your app happens to have that screen density, the density-specific resource will be used. As a result, -nodpi becomes a fallback, to be used in cases where you do not have something specific for a density.
阅读 CommonsBlog
关于android - 位图太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36133019/