【发布时间】:2016-03-21 13:59:13
【问题描述】:
我有一张1080x1920px 图像,我想在我的应用中用作背景图像。
在我的Galaxy S6 it 上工作正常,但是当我减小到较小的屏幕尺寸(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"/>
我的 MainActivity 是空的,除了 onCreate。 我已阅读有关此问题的其他帖子,但没有一个为我提供任何真正的解决方案。
【问题讨论】:
-
见 RomainGuy 的answer here
-
图像会根据您设备的像素密度进行缩放。图片实际上太大了。如果您希望它适用于所有位图,包括那些动态添加的位图,您可以确定 OpenGL 将允许的最大尺寸并调整位图的大小以适应它。关于@Shark 对 Romain 的回答的链接,您可能也想看看这个:stackoverflow.com/questions/26985858/…
-
你的图片在错误的文件夹中使用 drawable-nodpi 而不是 drawable stackoverflow.com/q/36113734/4267244
-
@DalijaPrasnikar 这实际上让它工作了!