Android 梯度背景不';有些设备不能工作
我正在为图像内部阴影使用可绘制的渐变,它在某些设备(检入模拟器)上运行良好,但在某些设备上不起作用。首先,我认为这将取决于设备的api级别,但今天我在api级别为“16”(即果冻豆)的平板电脑上检查相同的东西,但它也不起作用 渐变代码(用于所有四边的内部阴影):Android 梯度背景不';有些设备不能工作,android,android-layout,gradient,Android,Android Layout,Gradient,我正在为图像内部阴影使用可绘制的渐变,它在某些设备(检入模拟器)上运行良好,但在某些设备上不起作用。首先,我认为这将取决于设备的api级别,但今天我在api级别为“16”(即果冻豆)的平板电脑上检查相同的东西,但它也不起作用 渐变代码(用于所有四边的内部阴影): 我的布局代码: <FrameLayout android:id="@+id/about" android:layout_width="wrap_content"
我的布局代码:
<FrameLayout
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@color/light_green" >
<ImageView
android:id="@+id/home_icon_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/home_icon_placeholder" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="5dp"
android:drawableTop="@drawable/about_icon"
android:gravity="center"
android:text="@string/about_champions_club_btn_txt"
android:textColor="@android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</FrameLayout>
在我的代码中使用渐变,如下所示:
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
placeHolderImageViewAbout.setBackgroundColor(getResources().getColor(R.color.transparent));
} else {
//shadow background is above mention gradient
placeHolderImageViewAbout.setBackgroundResource(R.drawable.shadow_background);
}
intsdk=android.os.Build.VERSION.sdk\u int;
if(sdk
从shadow_background.xml中删除此块(第一个项目块)
<item>
<shape android:shape="rectangle" >
</shape>
</item>
您是否已检查硬件加速启用?看看沙拉菲的回答。@Toris-谢谢你的回答,但不要用这个。是的!!它成功了。。但是你能告诉我为什么这个形状属性在某些设备上不起作用吗?@Manish在某些设备上,形状的纯色默认为黑色(不透明)。
<item>
<shape android:shape="rectangle" >
</shape>
</item>
FrameLayout
(Background = @color/light_green)
LinearLayout
(Background = @drawable/shadow_background)