我正在尝试在 scrollview 中添加一个 webview,它可以显示具有透明背景的静态 HTML 文本。这是代码
WebView descr = (WebView) view.findViewById(R.id.description);
descr.setBackgroundColor(Color.TRANSPARENT);
descr.loadData(desc, "text/html", "utf-8");
descr.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
如果我不设置 setLayerType 值,我可以正确地看到文本。但是,当滚动完成时,它会增加闪烁效果。如果添加 setLayerType 行,某些页面的文本将消失。这是我的布局的样子
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:descendantFocusability="blocksDescendants">
<ImageView
android:id="@+id/icon"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:contentDescription="@id/title"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
<WebView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAlignment="gravity"
android:textSize="14sp"
android:background="@null"
android:focusable="false" />
</LinearLayout>
</ScrollView>
当我在我的手机上而不是在模拟器上安装 .apk 文件时会出现此问题。我正在使用 android 版本 4.1.2。谁能告诉我需要做什么才能使显示的文本没有闪烁效果并具有透明背景?
最佳答案
请将#android:layerType="software"# 添加到 WebView 和所有容器,直到 ScrollView。在 Android4.4 上,它适用于我。
<ScrollView
android:layerType="software"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title" >
<LinearLayout
android:layerType="software"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:descendantFocusability="blocksDescendants">
<ImageView
android:id="@+id/icon"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:contentDescription="@id/title"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
<WebView
android:layerType="software"
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textAlignment="gravity"
android:textSize="14sp"
android:background="@null"
android:focusable="false" />
</LinearLayout>
</ScrollView>
关于安卓 : Text disappears frequently in webview when LAYER_TYPE_SOFTWARE is set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18448862/
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
在我的系统中,我已经定义了STI。Dog继承自Animal,在animals表中有一个type列,其值为"Dog"。现在我想让SpecialDog继承自dog,只是为了在某些特殊情况下稍微修改一下行为。数据还是一样。我需要通过SpecialDog运行的所有查询,以返回数据库中类型为Dog的值。我的问题是因为我有一个type列,rails将WHERE"animals"."type"IN('SpecialDog')附加到我的查询中,所以我不能获取原始的Dog条目。所以我想要的是以某种方式覆盖rails在通过SpecialDog访问数据库时使用的值,使其表现得像Dog。有没有办法覆盖用于类型
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
如何将自己的字段类型添加到formtastic中?例如,我需要一个自定义的日期时间输入,我想要这样的东西::my_date%>这显然是行不通的,因为formtastic不知道:my_date(只有:boolean、:string、:datetime等等...)但是我怎样才能添加额外的输入类型呢? 最佳答案 您需要添加自定义输入法:classMyCustomFormtasticFormBuilder这非常适合新的HTML5输入类型。你可以这样使用它:MyCustomFormtasticFormBuilderdo|f|%>:my_dat
我在rails中有一个API端点,默认情况下,如果您没有设置任何Content-Typeheader,则会处理中的参数application/x-www-form-urlencoded有没有办法在不指定header中的内容类型的情况下处理来自POST请求的rails中的json字符串? 最佳答案 在您的routes.rb文件中,您可以将POST路由放置在命名空间中,并像这样定义预期的格式:namespace:api,defaults:{format::json}dopost'example'=>'controller#action'
我有以下代码:classProfileLookup基本上包含大量查找数据,按类别拆分。目的是为数据库中的每个类别创建一个方法。通过Rails控制台,此代码按预期工作:ruby-1.9.3@hub:002>ProfileLookup.available_gendersProfileLookupLoad(0.6ms)SELECT"profile_lookups".*FROM"profile_lookups"WHERE"profile_lookups"."category"='gender'ORDERBYvalue=>["Female","Male"]但是,我的规范不合格。以下规范:requ
我需要定义用于序列化/反序列化对象的自定义方法。我想做类似下面的事情。classPersondefto_yaml_type"!example.com,2010-11-30/Person"enddefto_yaml"stringrepresentingperson"enddeffrom_yaml(yaml)Person.load_from(yaml)endend声明序列化/反序列化的正确方法是什么? 最佳答案 好的,这就是我想出的classPersondefto_yaml_type"!example.com,2010-11-30/pe
require'net/http'require'rubygems'require'json'url=URI.parse('http://www.xyxx/abc/pqr')resp=Net::HTTP.get_response(url)#get_responsetakesanURIobjectdata=resp.bodyputsdata这是我在ruby中的代码,resp.data以xml形式提供给我数据。restapi默认返回xml数据,如果headercontent-type是application/json,则返回json。但我想要json格式的数据。为此我必须设置heade
我在从pggem中获取输入结果时遇到问题。require'pg'require_relative'spec/fixtures/database'client=PG.connect(DB[:pg])client.type_map_for_queries=PG::BasicTypeMapForQueries.new(client)client.type_map_for_results=PG::BasicTypeMapForResults.new(client)client.exec(%|select*fromtestme;|)do|query|query.each{|r|putsr.ins
我有一个用例,我想使用ActiveRecord::Relationupdate_all方法并指定要设置的几个字段。我使用update_all是因为可以更新很多条目,我不想将它们全部加载并一个一个地更新。其中一些需要直接的SQLSET语句,例如因为我根据另一列的值设置一列。是否有一个简单的语法与update_all一起使它可读,沿着这个=>MyModel.where(state::foo).update_all(['timespent=timespent+500',#Can'tbeanythingelsethanaSQLstatementstate::bar,#RegularRailsS