Android 为什么将带有alpha的ImageView放置在不透明的ImageView上时不可见?
在我的Android应用程序中,我会将一张具有一定透明度的图像放在最大不透明度的背景上。为了尝试这一点,我尝试创建一个相对布局,带有背景图像视图(创建背景,具有完全不透明度,alpha=1),在这个布局上是另一个具有低不透明度值(alpha)的图像视图。并且,在相同的相对布局中,还有一个带有一些指示的文本视图 很奇怪!在我的Android仿真器上,所有功能都正常工作。但在不止一个真实的设备中,我可以完美地看到背景图像视图和文本视图,但第二个图像视图(图像透明度较低的视图)是完全不可见的!为什么?谢谢,我在下面复制我的代码Android 为什么将带有alpha的ImageView放置在不透明的ImageView上时不可见?,android,android-imageview,transparency,opacity,Android,Android Imageview,Transparency,Opacity,在我的Android应用程序中,我会将一张具有一定透明度的图像放在最大不透明度的背景上。为了尝试这一点,我尝试创建一个相对布局,带有背景图像视图(创建背景,具有完全不透明度,alpha=1),在这个布局上是另一个具有低不透明度值(alpha)的图像视图。并且,在相同的相对布局中,还有一个带有一些指示的文本视图 很奇怪!在我的Android仿真器上,所有功能都正常工作。但在不止一个真实的设备中,我可以完美地看到背景图像视图和文本视图,但第二个图像视图(图像透明度较低的视图)是完全不可见的!为什么?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/controlImageView">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/controlImageViewBack"
android:focusableInTouchMode="false"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="@drawable/bck_main"
android:alpha="1"
android:layout_weight="1"
android:contentDescription="@string/desc_img_control_background"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/controlImageViewPicture"
android:scaleType="fitStart"
android:src="@drawable/ctrl_bck"
android:focusableInTouchMode="false"
android:paddingTop="10dp"
android:alpha="0.5"
android:paddingBottom="10dp"
android:layout_alignTop="@id/controlImageViewBack"
android:contentDescription="@string/desc_img_control_picture"/>
<TextView android:id="@+id/controlMessageText" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_alignTop="@id/controlImageViewBack"
android:textSize="@dimen/board_text_size"
android:textColor="@color/colorButtonText"
android:textAlignment="center" android:gravity="center"
android:text="@string/mod_control_nomessage"/>
</RelativeLayout>
首先,重量和布局自动定向对相对布局没有任何影响 代码在我的Nexus 5X上运行 您使用的是什么真正的设备?已解决!从日志: 05-01 12:46:12.288 24904-24904/com.mycompany.myapp W/OpenGLRenderer:位图太大,无法上载到纹理(840x2524,最大值=2048x2048)
非常奇怪,但我第一次看到在某些图形元素中不可能插入太大的图像。感谢您的快速回答!三星Galaxy Nexus、安卓4.3(最小版本与app 4.0兼容)。在此设备上,背景图像视图和文本视图可见,但图片图像视图不可见(alpha值较低)。在设置内容视图后,您可能应该为图像视图记录以下值:宽度/高度/alpha值您可以向我们显示我们可以帮助您的日志操作系统吗?已经完成,并且已经解决。请看我先前的回答。感谢