我正在测试新的Appcompat 21 Material Design功能.因此我创建了一个这样的工具栏:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>
Run Code Online (Sandbox Code Playgroud)
并将其包含在我的主布局文件中.
然后我将它设置为supportActionBar:
Toolbar toolBar = (Toolbar)findViewById(R.id.activity_my_toolbar);
setSupportActionBar(toolBar);
Run Code Online (Sandbox Code Playgroud)
它工作,但不知何故,我无法弄清楚如何自定义工具栏.它是灰色的,上面的文字是黑色的.我该如何更改背景和文字颜色?
我已经完成了这个指示:
http://android-developers.blogspot.de/2014/10/appcompat-v21-material-design-for-pre.html
我有什么要改变颜色的?
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowActionBar" tools:ignore="NewApi">false</item>
<item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:
我可以通过在主题中添加以下代码行来更改背景颜色:
<item name="colorPrimary">@color/actionbar</item>
<item name="colorPrimaryDark">@color/actionbar_dark</item>
Run Code Online (Sandbox Code Playgroud)
但它们不会影响文字颜色.我错过了什么?我宁愿选择白色文字和白色菜单按钮,而不是黑色文字和黑色菜单按钮:

android android-appcompat android-actionbar android-actionbar-compat android-toolbar
我刚刚更新了我的Android Studio,现在我的项目将不再构建.我收到以下错误:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
Run Code Online (Sandbox Code Playgroud)
我没有改变任何东西,在更新之前一切正常.这是我的build.gradle档案:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ochs.pipette"
minSdkVersion 10
targetSdkVersion 21
versionCode 8
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies …Run Code Online (Sandbox Code Playgroud) 我想知道如何更改支持库22.2.0中的浮动操作按钮颜色?我试过了
button.setBackgroundColor(color);
Run Code Online (Sandbox Code Playgroud)
但显然,这会改变按钮的可绘制性并变为正方形.
现在我想知道如何改变颜色而不仅仅是颜色,而不会触及形状?
提前致谢
我正在尝试实现NavigationDrawer自上一次Android主题演讲以来提供的新功能.
我把所有东西都搞定了,当按下左上角的图标时,导航抽屉会打开和关闭.
但是现在我仍然有箭头图标,虽然我用Android中的ic_drawer替换了它.为什么?
这是我指定图标的代码:
mDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
R.drawable.ic_drawer, //<-- This is the icon provided by Google itself
R.string.drawer_open,
R.string.drawer_close
)
Run Code Online (Sandbox Code Playgroud)
但该应用程序仍然使用标准图标运行setDisplayHomeAsUpEnabled.
有任何想法吗?
我试图获得图像每个像素的每种颜色.我的想法如下:
int[] pixels;
BufferedImage image;
image = ImageIO.read(this.getClass.getResources("image.png");
int[] pixels = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();
Run Code Online (Sandbox Code Playgroud)
是对的吗?我甚至无法检查"像素"数组包含什么,因为我得到以下错误:
java.awt.image.DataBufferByte cannot be cast to java.awt.image.DataBufferInt
Run Code Online (Sandbox Code Playgroud)
我只是希望得到阵列中每个像素的颜色,我该如何实现呢?
我有一个包含EditText视图的简单TextInputLayout.
现在我想知道如何以编程方式更改强调颜色(下划线,突出显示时为hintTextColor).我似乎无法在TextInputLayout中找到合适的方法.
有什么建议?提前致谢.
我用新的Appcompat v21工具栏创建了一个活动.除非我从TextView中突出显示某些文本,否则一切正常.复制/剪切操作栏显示,但不是覆盖我现有的工具栏或隐藏它只是按下工具栏,所以我得到这样的东西:

现在我的问题是,如何使复制/剪切操作栏覆盖我的工具栏?或者,如果选择了文本,我应该隐藏它吗?如果是这样,我该如何收听文本选择?
最好的祝福
我正在尝试为 google play 服务授权我的 android 游戏,以便能够使用排行榜等。
现在当点击授权应用程序时,什么都不会发生。在信息页面上,谷歌告诉我做以下事情:

我将指定我的应用程序 ID,但是我从哪里获得这个“app_id”?还有成就id?排行榜ID?
这个 ids.xml 应该是什么样子的?
有任何想法吗?
我正在尝试将一个Object对齐到我的round_layout的角落,以获得圆形的android服装设备.正如你在这里看到的:

数字时钟将超出界限.
我在google IO 2014上看过android的文档,有些人表示,有一行代码,以便正确对齐对象.我希望数字时钟位于左上角,但不在屏幕外.
有没有人有建议?
这是XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity"
tools:deviceIds="wear_round">
<DigitalClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:textSize="20sp"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:
对于圆形活动,我的xml布局文件现在看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567890"
app:layout_box="top"/>
</android.support.wearable.view.BoxInsetLayout>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我尝试使用BoxInsetLayout,但仍然是输出如下:

虽然我用过
app:layout_box="top"
Run Code Online (Sandbox Code Playgroud)
TextView超出了屏幕的界限.我有什么监督?
我有一个surfaceview和一个gameThread类.gameThread不断更新和绘制SurfaceView类.
现在,当我退出应用程序时(通过按下主页或后退按钮),我收到一条消息,表明应用程序已关闭.那是因为GameThread仍然试图在擦除的surfaceview上画画......
那么如何在不获得此强制关闭通知的情况下正确结束应用程序?我希望GameThread类在按下后退按钮时停止.当按下主页并在后台运行时它应该暂停.当重新进入仍然运行的游戏时,它应该恢复....
有任何想法吗?
这是我的GameThread类:
public class GameThread extends Thread{
private GameView view;
public boolean isRunning = false;
public GameThread(GameView view) {
this.view = view;
}
public void setRunning(boolean setRunning) {
isRunning = setRunning;
}
public void run() {
while(isRunning) {
Canvas c = null;
view.update();
try {
c = view.getHolder().lockCanvas();
synchronized (view.getHolder()) {
view.draw(c);
}
}finally {
if(c != null) {
view.getHolder().unlockCanvasAndPost(c);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它不断更新我的GameView类:
公共类GameView扩展了SurfaceView {
private GameThread gameThread;
public GameView(Context context, Activity activity) {
super(context); …Run Code Online (Sandbox Code Playgroud) android ×9
colors ×2
java ×2
drawer ×1
exit ×1
image ×1
navigation ×1
pixel ×1
surfaceview ×1
wear-os ×1