Akh*_*ain 7 android android-layout android-5.0-lollipop
我设计了屏幕,我使用JPEG图像作为布局背景.在Android 8(GingerBread)到Android 19(Kitkat)中可以正确显示完整的UI屏幕.在Android 20+(Lollipop)中看不到布局背景
我正在使用App Compatibility Library.
请参见下面的截图
模拟器Android 8
设备Kitkat
设备棒棒糖
解决方案已经尝试
@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>
Run Code Online (Sandbox Code Playgroud)
styles.xml,值为-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>
Run Code Online (Sandbox Code Playgroud)
登录按钮可绘制
<?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>
Run Code Online (Sandbox Code Playgroud)
编辑1:添加了Styles.xml和按钮drawables 编辑2:提到支持库的使用
经过长时间的测试和尝试,我终于意识到..代码、xml、样式或主题设置没有任何问题。
问题堆栈中的小针是“防止位图太大而无法上传到纹理 android”
原因是,当在屏幕上渲染图像时,OpenGLRenderer 没有加载高分辨率设备的位图,因此 Nexus 设备上没有图像。
我使用的解决方法是在onCreate()方法中以编程方式手动调整位图大小,并将其设置为布局的背景。
希望对无法加载背景的人有所帮助。
想了解更多欢迎来询问!!
| 归档时间: |
|
| 查看次数: |
3482 次 |
| 最近记录: |