我试图在Android 5.0中将ListView中的图像与详细信息页面之间进行英雄转换.但是对于我的大约50%的图像,Android崩溃,但下面有例外.我的图像是600x400,但我尝试将它们更改为200x100,但得到了同样的错误.当它工作时,它看起来很棒,但我看不出各种图像之间的差异.真的不确定为什么它声称这个图层太大了,有人知道吗?
private void handleNewsItemClicked(AdapterView<?> arg0, View viewClicked, int arg2) {
TopNewsItem item = ((TopNewsItem)arg0.getAdapter().getItem(arg2));
Intent intent = new Intent(getActivity(), TopNewsDetailsActivity.class);
intent.putExtra(TopNewsDetailsActivity.ARGS_ID, item.getGuid().getId());
intent.putExtra(TopNewsDetailsActivity.ARGS_IMAGE, imageUrl);
if(Build.VERSION.SDK_INT >= 21) {
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(this.getActivity(),
viewClicked.findViewById(R.id.image), "article_image");
this.getActivity().startActivity(intent, options.toBundle());
}else
getActivity().startActivity(intent);
}
}
W/OpenGLRenderer(18137): Layer exceeds max. dimensions supported by the GPU (1080x4628, max=4096x4096)
D/AndroidRuntime(18137): Shutting down VM
V/GAV3 (18137): Thread[main,5,main]: Tracking Exception: IllegalStateException (@MessageQueue:nativePollOnce:-2) {main}
/AndroidRuntime(18137): FATAL EXCEPTION: main
E/AndroidRuntime(18137): Process: myapp.app, PID: 18137
E/AndroidRuntime(18137): java.lang.IllegalStateException: Unable to create layer …Run Code Online (Sandbox Code Playgroud) 我想创建一个自定义高度工具栏,它工作正常,直到我添加内容.然后我的内容被调整为在后退箭头和操作栏按钮之间.
如何让我的内容占据整个宽度,以便我可以创建如下的布局?我想"+"图标需要在工具栏的父布局中?
文档说:
应用程序可能会向工具栏添加任意子视图.它们将出现在布局中的这个位置.如果子视图的Toolbar.LayoutParams指示CENTER_HORIZONTAL的重力值,则在测量完所有其他元素后,视图将尝试以工具栏中剩余的可用空间为中心.
但我没有将重力设置为CENTER_HORIZONTAL ......

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:iosched="http://schemas.android.com/apk/res-auto"
iosched:theme="@style/ActionBarThemeOverlay"
iosched:popupTheme="@style/ActionBarPopupThemeOverlay"
android:id="@+id/toolbar_actionbar"
android:background="@color/theme_primary"
iosched:titleTextAppearance="@style/ActionBar.TitleText"
iosched:contentInsetStart="16dp"
iosched:contentInsetEnd="16dp"
android:layout_width="match_parent"
android:layout_height="128dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
... My Content
Run Code Online (Sandbox Code Playgroud)
目前,当左边距设置为168时,我的布局会像这样结束:

我有一些带有白色背景的图像和一些带有透明背景的图像.当创建它们的圆形图像时,我希望它们都具有白色背景,所以基本上我想用白色像素替换图像的透明像素.
有没有办法实现这一点,而不是逐个替换像素?这是我用于创建圆角图像的转换:
package com.mobilefootie.util;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
public class RoundedTransformation implements com.squareup.picasso.Transformation {
public RoundedTransformation() {
}
@Override
public Bitmap transform(final Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
source.recycle();
}
Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());
Canvas …Run Code Online (Sandbox Code Playgroud) 根据指南:https: //developer.android.com/design/wear/patterns.html#Continuing
"如果必须使用手机,一旦点击操作按钮,就会播放通用动画,并在手机上打开相应的Android应用程序."
动画可以在Google Keep应用中看到.以下是录制示例:https: //dl.dropboxusercontent.com/u/25670071/IMG_0274.MOV
某个地方有这个动画的标准实现吗?
我在我的应用程序中添加了两个按钮,设置为目标API级别8.问题是两个按钮显示为两个大的灰色按钮,与其余通知完全不同.我已经在Nexus 7和Galaxy Nexus上测试了它.

我见过的所有例子都有漂亮的黑色按钮,如来电通知:http: //www.androidng.com/wp-content/uploads/2012/07/android-jelly-bean-notifications.jpeg
我猜这很容易,但今天没有这样的运气.有谁知道我可能走错了路?下面是我的代码片段,它使用最新的支持库生成通知.
NotificationManager nm = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
android.support.v4.app.NotificationCompat.Builder builder = new android.support.v4.app.NotificationCompat.Builder(this);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_stat_radio)
.setContentTitle(message)
.setTicker(message)
.setPriority(android.support.v4.app.NotificationCompat.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setAutoCancel(false)
.addAction(android.R.drawable.ic_btn_speak_now, "Play", contentIntent)
.addAction(android.R.drawable.ic_dialog_map, "Stop", contentIntent)
.setContentText(message);
Notification n = builder.build();
//nm.notify(0, n);
startForeground(1, n);
Run Code Online (Sandbox Code Playgroud) 我有一个非字母顺序的国家列表视图,并开始使用fastscroll.我想在使用fastscroll滚动时显示country-flag,但似乎API将FastScroll类作为私有,因此我无法覆盖它.
有没有其他人实现自定义快速滚动视图?
参考文献:http://developer.android.com/reference/android/widget/AbsListView.html#attr_android : fastScrollEnabled
我已经实现了"旧的"GCM实现,其中示例代码具有以下内容:
public static final String PROPERTY_REG_ID = "registration_id";
private SharedPreferences getGCMPreferences(Context context) {
return context.getSharedPreferences(SampleApp.class.getSimpleName(),
Context.MODE_PRIVATE);
}
...
String registrationId = prefs.getString(PROPERTY_REG_ID, "");
Run Code Online (Sandbox Code Playgroud)
使用Android 6.0中的新备份系统,它表示您应该排除此密钥,但排除格式文档:http: //developer.android.com/training/backup/autosyncapi.html
似乎并没有真正表明如何排除共享偏好,除了说:
sharedpref:指定getSharedPreferences()方法返回的SharedPreferences对象.
根据我的知识,没有没有参数的getSharedPreferences()?
我试过了:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="sharedpref" path="registration_id"/>
</full-backup-content>
Run Code Online (Sandbox Code Playgroud)
但这似乎并不自然,因为我没有指出它应该排除哪个共享首选项文件.有人成功实现了吗?
我正在尝试为MonoTouch实现推送通知,但我无法在任何地方找到这样的样本.我的问题是尝试将deviceID读入.NET字符串.
下面的输出只是很多问号所以我在这里做错了.
任何帮助将不胜感激!
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
Console.WriteLine("Converting device ID...");
NSString s = NSString.FromData(deviceToken, NSStringEncoding.UTF8);
Console.WriteLine("DEVICE ID IS: " + s);
s = NSString.FromData(deviceToken, NSStringEncoding.ASCIIStringEncoding);
Console.WriteLine("DEVICE ID IS: " + s);
s = NSString.FromData(deviceToken, NSStringEncoding.Unicode);
Console.WriteLine("DEVICE ID IS: " + s);
}
Run Code Online (Sandbox Code Playgroud) 我尝试了各种关于片段动画的样本,但没有任何反应,所以DialogFragment不是一个"正确的"片段吗?或者我在这里遗漏了什么?
FragmentTransaction ft = getFragmentManager().beginTransaction();
InfoDialogFragment newFragment = InfoDialogFragment.newInstance();
newFragment.setAsset(mainShow, c,backgroundDrawable);
ft.setCustomAnimations(R.anim.grow_in, R.anim.fadeout);
ft.add(newFragment, "dialog");
ft.commit();
...
public class InfoDialogFragment extends DialogFragment {
Run Code Online (Sandbox Code Playgroud) 我想在使用新材料主题和AppCompat 21时将SearchView放在平板电脑上.这可能或者我必须将自己的自定义布局添加到工具栏吗?

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mnuSearch = menu.findItem(R.id.menu_search);
android.support.v7.widget.SearchView searchView = (SearchView) MenuItemCompat.getActionView(mnuSearch);
searchView.setGravity(Gravity.LEFT);
searchView.setIconifiedByDefault(false);
searchView.setQueryHint(getString(R.string.search));
searchView.requestFocus();
return true;
}
Run Code Online (Sandbox Code Playgroud)