我有一个简单的Button:
<Button
android:id="@+id/test"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
并尝试通过以下方式更改文本属性:
SpannableString span = new SpannableString(text);
span.setSpan(new AbsoluteSizeSpan(8, true), 5, 10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
testButton.setText(span);
Run Code Online (Sandbox Code Playgroud)
它适用于Android 4.3但不适用于5.0.
有趣的是,当我将实现更改Button为TextView5.0时,它可以正常工作.似乎是Button棒棒糖的东西.
当我在源代码中进行一些更改时,Android Studio(实际上是gradle)需要重建项目.很明显.
为什么即使我没有对项目进行任何更改,第二次构建也会像第一次构建那样花费几乎相同的时间?当我查看GradleConsole时,它会等待"assembleDubug"任务.我认为gradle应该意识到没有变化,不应该浪费太多时间.
我已将我的项目从4.2.2更新到Node 6.0.0.
我发现node-inspector不会工作并在一段时间后导致控制台日志中的"内部错误:非法访问"(每个新的调试会话都不同).
当我切换回4.2.2时,一切正常.
如何配置node-inspector使其与Node 6.0.0一起使用?
当我提交时,我选择了"下次不显示此对话框".我想更改更新项目选项,但我不知道如何强制IntelliJ再次显示此对话框.我在IntelliJ设置中搜索过,但我没有找到任何关于此问题的内容.需要帮忙 :)
我创建了简单的Base64Images辅助类,其中包含此主体:
companion object{
val ABSTRACT_COLORS = "[image encoded in base64]"
}
Run Code Online (Sandbox Code Playgroud)
ABSTRACT_COLORS实际上是一个有 570438 个字符的字符串。
在编译过程中我得到:
org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate property ABSTRACT_COLORS
...
...
The root cause was thrown at: ByteVector.java:213 at org.jetbrains.kotlin.codegen.MemberCodegen.genFunctionOrProperty(MemberCodegen.java:205)
Caused by: java.lang.IllegalArgumentException
Run Code Online (Sandbox Code Playgroud)
我认为我可以在字符串中存储2147483647 (2 31 - 1) 个字符。
这是为什么?
我在下面发布了这张图片。
您可以使用此工具生成base64。
提示:编辑此类或编译项目会冻结 Android Studio。
我会使用一些轻量级编辑器来编辑并使用终端来编译它。
我有livewallpaper,livewallpaper的设置活动以及标准的MainActivity.关键是livewallpaper不能与MainActivity一起使用.当我的清单看起来像这样:
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.BIND_WALLPAPER"/>
<uses-feature android:name="android.software.live_wallpaper" />
<application android:icon="@drawable/icon"
android:label="simea">
<!-- >android:permission="android.permission.BIND_WALLPAPER">-->
<service android:name=".LiveWallpaper"
android:label="@string/app_name"
android:icon="@drawable/icon">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="@xml/livewallpaper" />
</service>
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/livewallpaper_settings"
android:name=".LiveWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon="@drawable/icon">
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
我可以运行MainActivity,但我不能将livewallpaper与我的主屏幕绑定.我看到livewallpaper的预览,我可以更改设置,但是当我点击"设置壁纸"按钮时,没有任何效果.
当我取消注释这一行时:
<!-- >android:permission="android.permission.BIND_WALLPAPER">-->
Run Code Online (Sandbox Code Playgroud)
并评论这个:
<uses-permission android:name="android.permission.BIND_WALLPAPER"/>
Run Code Online (Sandbox Code Playgroud)
livewallpaper在我的主屏幕上工作得很好,但是当我尝试运行MainActivity时,我得到了这样的消息:"app没有安装在你的手机上".我该如何解决?