我的应用(游戏)的主菜单使用标准的 Android 按钮。它在我的所有设备上运行良好,但Nexus 7 with Android 4.4.2 除外。问题如下:
在以下任一情况下,按钮的文本突然消失:
setEnabled(boolean) 在按钮上调用例如,如果我按下“加载游戏”,按钮在按下事件期间正确突出显示,但“加载游戏”完全消失(按钮的文本为空)。
如果我删除所有自定义样式和行为,并仅使用默认 Android 按钮和默认字体等,问题仍然存在。
如果我将 targetSdkVersion 降低到 18(从 19),即使在 Nexus 7 上也一切正常。
知道 KitKat 在这方面发生了什么变化吗?我没有发现任何可疑的东西。
我的重要 XML 代码:
<TableLayout
android:id="@+id/layoutGameMainmenu"
android:layout_width="wrap_content"
android:layout_height="83dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:gravity="center_vertical"
android:visibility="gone" >
<TableRow>
<Button
android:id="@+id/buttonLoadGame"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="2dip"
android:layout_marginRight="30dip"
android:background="@drawable/button_gamemainmenu"
android:text="buttonLoadGame"
android:textColor="@color/button_gamemainmenu_text"
android:textScaleX="0.9"
android:textSize="16dp" />
<Button
android:id="@+id/buttonSettings"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="2dip"
android:layout_marginLeft="30dip"
android:background="@drawable/button_gamemainmenu"
android:text="buttonSettings"
android:textColor="@color/button_gamemainmenu_text"
android:textScaleX="0.9"
android:textSize="16dp" />
</TableRow>
<TableRow>
<Button
android:id="@+id/buttonStartGame"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="1dip"
android:layout_marginRight="30dip"
android:background="@drawable/button_gamemainmenu"
android:text="buttonStartGame"
android:textColor="@color/button_gamemainmenu_text"
android:textScaleX="0.9"
android:textSize="16dp" />
<Button
android:id="@+id/buttonQuit"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="1dip"
android:layout_marginLeft="30dip"
android:background="@drawable/button_gamemainmenu"
android:text="buttonQuit"
android:textColor="@color/button_gamemainmenu_text"
android:textScaleX="0.9"
android:textSize="16dp" />
</TableRow>
</TableLayout>
关于上述代码的重要说明:
android:textColor 和 android:background 属性。在这种情况下,我的按钮将具有默认外观(而不是它们的游戏特定样式),但问题仍然存在。最后,关于我的全局样式/主题的一些信息:
在 AndroidManifest 中,我将 Application 主题设置为 MyCustomTheme。 mycustomtheme.xml内容:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:soundEffectsEnabled">false</item>
</style>
</resources>
最后,我的 styles.xml 如下(但似乎我没有从任何地方引用它的样式,这似乎是我们制作全屏游戏时的旧代码,或者Android 默认在任何地方使用它?):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="android:Theme">
</style>
<style name="Theme.TranslucentWoTitle" parent="android:Theme.Translucent">
<item name="android:windowNoTitle">true</item>
</style>
</resources>
最佳答案
查看您的 XML 文件,我仍然认为您的项目中存在问题。
这个最小的示例不会在 Nexus 7 2013 4.4.2(minSDK=8,targetSDK=19)上重现问题:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
获取您的 XML 并删除背景/文本颜色也不会重现它:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="@+id/layoutGameMainmenu"
android:layout_width="wrap_content"
android:layout_height="83dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:gravity="center_vertical">
<TableRow>
<Button
android:id="@+id/buttonLoadGame"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="2dip"
android:layout_marginRight="30dip"
android:text="buttonLoadGame"
android:textScaleX="0.9"
android:textSize="16dp" />
<Button
android:id="@+id/buttonSettings"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="2dip"
android:layout_marginLeft="30dip"
android:text="buttonSettings"
android:textScaleX="0.9"
android:textSize="16dp" />
</TableRow>
<TableRow>
<Button
android:id="@+id/buttonStartGame"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="1dip"
android:layout_marginRight="30dip"
android:text="buttonStartGame"
android:textScaleX="0.9"
android:textSize="16dp" />
<Button
android:id="@+id/buttonQuit"
android:layout_width="174dip"
android:layout_height="40dip"
android:layout_marginBottom="1dip"
android:layout_marginLeft="30dip"
android:text="buttonQuit"
android:textScaleX="0.9"
android:textSize="16dp" />
</TableRow>
</TableLayout>
</RelativeLayout>
最后,我注意到 android:textColor="button_gamemainmenu_text",这不是默认的 Android 行为,建议您以自己的方式处理文本颜色。我坚信删除此自定义行为将解决问题。
关于java - KitKat 上的按钮文本消失(API 级别 19),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23588733/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
我有用于控制用户任务的Rails5API项目,我有以下错误,但并非总是针对相同的Controller和路由。ActionController::RoutingError:uninitializedconstantApi::V1::ApiController我向您描述了一些我的项目,以更详细地解释错误。应用结构路线scopemodule:'api'donamespace:v1do#=>Loginroutesscopemodule:'login'domatch'login',to:'sessions#login',as:'login',via::postend#=>Teamroutessc
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht