我设计了使用 JPEG 图像作为布局背景的屏幕。完整的 UI 屏幕在 Android 8 中正确可见(姜饼) 至 Android 19(Kitkat)。布局背景在 Android 20+ 中不可见(Lollipop)
我正在使用应用程序兼容性库.
请参阅下面的屏幕截图
模拟器安卓8
设备奇巧
设备棒棒糖
已经尝试过的解决方案
- 创建另一个文件夹mipmap并在那里复制相同的图像并尝试使用访问它
@mipmap\image_background
. 没有改变.
布局XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/mainBody"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- android:background="@drawable/login_bg" -->
<View
android:id="@+id/vwStruts"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true" />
<TableLayout
android:id="@+id/tblLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="5dp"
android:padding="5dp" >
<TableRow
android:id="@+id/tbrUserId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center" >
<EditText
android:id="@+id/edtUserId"
style="@style/EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/hintEmpId" >
<requestFocus />
</EditText>
</TableRow>
<TableRow
android:id="@+id/tbrPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
>
<EditText
android:id="@+id/edtPassword"
style="@style/EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:ems="10"
android:hint="@string/hintPassword"
android:inputType="textPassword" />
</TableRow>
<TableRow
android:id="@+id/tbrLoginAndClear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="@+id/btnLogin"
style="@style/LoginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="40dp"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="@string/login" />
</TableRow>
</TableLayout>
<ImageView
android:id="@+id/imgLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/tblLogin"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/tblLoginMargin"
android:src="@raw/footer_logo" />
</RelativeLayout>
styles.xml,没有values-v21的文件夹
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
登录按钮可绘制
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- On Pressed state -->
<item android:state_pressed="true" >
<shape>
<solid android:color="@color/btn_login_on_press" />
</shape>
</item>
<!-- enabled true Not pressed, normal state -->
<item android:state_pressed="false" android:state_enabled="true">
<shape>
<solid android:color="@color/btn_login_normal" />
</shape>
</item>
</selector>
编辑 1:添加了 Styles.xml 和按钮可绘制对象
编辑 2:提及支持库的使用
假设您正在应用可绘制的 using 样式,您可能忘记在 v21 文件夹中编辑其他样式(如果存在)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)