根据我的代码运行新的Lint工具.它提出了很多好的建议,但这个我无法理解.
此标签及其子代可以替换为一个和复合drawable
问题:检查当前节点是否可以使用复合drawables替换为TextView.
包含ImageView和TextView的LinearLayout可以作为复合drawable更有效地处理
这是我的布局
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/upImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/up_count_big">
</ImageView>
<TextView
android:id="@+id/LikeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginBottom="1dp"
android:textColor="@color/gray"
android:textSize="16sp"
android:layout_gravity="center_vertical">
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,有人能提供一个如何制作复合可绘制的具体例子吗?
android textview android-layout android-linearlayout compound-drawables
我在整个应用程序中使用Helvetica字体.目前我正在与资产分开创建字体.所以我说这三个
HelveticaNeue = Typeface.createFromAsset(application.getAssets(), "fonts/HelveticaNeue.ttf");
HelveticaNeueBold = Typeface.createFromAsset(application.getAssets(), "fonts/HelveticaNeueBold.ttf");
HelveticaNeueBoldItalic = Typeface.createFromAsset(application.getAssets(), "fonts/HelveticaNeueBoldItalic.ttf");
Run Code Online (Sandbox Code Playgroud)
当我为一个TextView使用一种字体时,一切都很好用.但是,我需要使用spannable
Spannable WordtoSpan = new SpannableString("This text should be normal, but this needs to be bold, and normal");
WordtoSpan.setSpan(new TypefaceSpan("bold"), 5, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Run Code Online (Sandbox Code Playgroud)
而且我想让部分字符串为HeleveticaNeueBold,而有些则只是HelveticaNeue.我认为我需要的是向Android表明上面的3种字体实际上是相关的,以便它可以很好地切换它们.寻找任何其他方式来做到这一点.
我有一个ListView
,我希望在活动结束时从内存中清除它.但是,它似乎正在泄漏.当我检查了内存转储,并得到pathToGC
了ListView
我得到以下,
Class Name | Shallow Heap | Retained Heap
android.widget.ExpandableListView @ 0x4063e560 | 768 | 39,904
|- list, mList com.hitpost.TeamChooser @ 0x405f92e8 | 176 | 1,648
| '- mOuterContext android.app.ContextImpl @ 0x40657368 | 160 | 304
| '- mContext android.media.AudioManager @ 0x40662600 | 40 | 168
| '- this$0 android.media.AudioManager$1 @ 0x406626b0 Unknown| 24 | 24
Run Code Online (Sandbox Code Playgroud)
我看到同样的情况泄漏了很多我的ListView's
.诀窍是,我根本没有AudioManager
在我的应用程序中使用任何地方,根本没有来自应用程序的声音.请帮忙,这让我发疯了.显然是想弄清楚为什么会发生这种情况以及可能是根本问题?
我已经用这个问题撞了桌子3天了,请告诉我我误入歧途的地方.
当我收到传入的VoIP电话时,我正在尝试显示全屏通知,就像PhoneApp那样.如果用户处于身临其境的活动中,我可以抬起头来.但是,我只收到抬头通知,并且从未获得全屏.我也需要通知忽略锁定屏幕.
这是我在做的事情:
String callJson = call.toJson(uber).toString();
uber.requestWakeState(UberVoice.WAKE_STATE_FULL);
final Notification.Builder builder = new Notification.Builder(uber);
builder.setSmallIcon(R.drawable.switch_notification);
if (image != null) {
builder.setLargeIcon(image);
}
builder.setOngoing(true);
PendingIntent inCallPendingIntent =
PendingIntent.getActivity(uber, 234,
UberVoice.createInCallIntent(), 0);
builder.setContentIntent(inCallPendingIntent);
builder.setContentText(body);
builder.setUsesChronometer(false);
builder.setContentTitle(title);
builder.setCategory(Notification.CATEGORY_CALL);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), AudioManager.STREAM_RING);
builder.setVibrate(new long[]{500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500});
builder.setPriority(Notification.PRIORITY_MAX);
builder.setTicker(title);
builder.setFullScreenIntent(inCallPendingIntent, true);
builder.addAction(R.drawable.hangup_action, "Reject", CallService.getPendingIntent(uber, callJson, CallService.REJECT));
builder.addAction(R.drawable.answer_action, "Answer", CallService.getPendingIntent(uber, callJson, CallService.ANSWER));
NotificationManager notificationManager = (NotificationManager) uber.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = builder.build();
notificationManager.notify(INCOMING_CALL_NOTIFICATION_ID, notification);
Run Code Online (Sandbox Code Playgroud)
这是creatCallIntent代码:
public …
Run Code Online (Sandbox Code Playgroud) 我试图拦截我的应用程序的几个不同的链接,我在使用intent-filter数据参数时遇到问题.
以下是我想要拦截的两种类型的链接
我已经决定有一个单独的活动来拦截这两个链接并使用java正则表达式来启动正确的活动.但是我似乎无法捕获这两种格式而没有捕获像http://www.domain.com/abc123这样的东西
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="www.domain.com"
android:pathPattern="/#id.*" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
这就是我目前正在尝试拦截类型1,并且由于某种原因它无法正常工作.
此intent-filter正确截取类型2
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="domain.com" />
<data android:host="www.domain.com" />
<data android:pathPrefix="/share/web" />
<data android:pathPrefix="/social/landing" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
谢谢,
android intentfilter android-manifest android-intent android-activity
我有一个相当复杂的项目库.每个项目由图像和2个按钮组成.当画廊加载一切正常时,按钮按照预期进行操作,按钮的按下状态仅在实际按下按钮时发生.
但是,只要我滚动图库,按钮就会停止工作,单击任意位置会启用按钮的按下状态.
我已经尝试将所有内容嵌入到LinearLayout中,但是根据这个答案没有传递OnDown事件,但这只会阻止点击事件.
我知道Gallery不是这种复杂布局的理想小部件,但我想知道是否有更好的解决方法来解决这个问题.
更新:
我会尝试解释一下这个架构.我有一个FragmentActivity,它包含一个ListFragment,它只由一个ListView组成.
ListView由较小元素组(Bettable)和一些元信息组成.这些组实现为Gallerys.具体来说,我有扩展的Gallery(称为OneGallery),它做了几件事,它确保一次只滚动一个项目,并在滚动发生时转换图库项目.这是代码
这是Bettable布局的代码
我正在尝试设置在Eclipse中为我的Android项目使用Maven和pom.xml文件.我有Eclipse Indigo设置(包括m2e),安装了Android SDK,安装了ADT.我正在努力理解"安装m2e-android-plugin"意味着什么(我总是被带到这个页面,它提供了安装它的说明,但我无法遵循)具体来说,当我浏览该页面上的指令时,在完成第2部分中的所有步骤后,我的结构没有"Maven Dependencies",我的pom.xml文件显示以下错误:
Project build error: Unresolveable build extension: Plugin
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1 or one of its dependencies could
not be resolved: The following artifacts could not be resolved:
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1,
com.android.ddmlib:ddmlib:jar:r16, org.sonatype.sisu:sisu-inject-bean:jar:2.1.1,
org.sonatype.sisu:sisu-guice:jar:no_aop:2.9.4, org.codehaus.plexus:plexus- archiver:jar:2.0.1, junit:junit:jar:3.8.1,
org.codehaus.plexus:plexus-io:jar:2.0.1, org.codehaus.plexus:plexus-utils:jar:3.0, commons-jxpath:commons-
jxpath:jar:1.3, commons-io:commons-io:jar:2.0.1, org.ow2.asm:asm:jar:4.0, commons-lang:commons-lang:jar:
2.6, org.sonatype.aether:aether-util:jar:1.12: Failure to transfer
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central
has elapsed or updates are forced. Original error: Could not …
Run Code Online (Sandbox Code Playgroud) 我使用Volley和NetworkImageView.这对几个项目来说非常有用.但是我现在需要在标题中为我的图像请求发送auth令牌.做这个的最好方式是什么?在我的正常请求中,我覆盖getHeaders()并以这种方式放置我的令牌.但ImageLoView使用的ImageLoader会生成一个通用的Request,这使得很难添加标题......
不确定这是否可能,但希望有人有解决方案。
我试图让我的 Android 应用程序拦截 mydomain.com/abc 但不是 mydomain.com/mp3/id 形式的网址
是否可以使用 pathPattern 以某种方式排除某些路径?
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="mydomain.com" />
<data android:pathPattern="/.*" /> />
</intent-filter>
Run Code Online (Sandbox Code Playgroud) 我使用SlidingDrawer作为我的主要布局.在内容区域内我有一个片段(包含ListView)当活动首次加载时,一切都很棒,列表视图正确滚动.
当我开始一个不同的活动然后回来时,我尝试的第一个滚动动作被SlidindDrawer拦截,并打开或关闭它.只要您停止滚动并拿起手指,ListView就可以再次滚动.
我希望ListView能够在活动恢复时滚动.而且通常能够控制SlidingDrawer是否是获得焦点的人.
更新:
我把问题缩小了一点.我已经扩展了SLidingDrawer以允许使用以下代码单击句柄中的按钮.
Override
public boolean onInterceptTouchEvent(MotionEvent event) {
super.onInterceptTouchEvent(event);
if (mHandleLayout != null) {
int clickX = (int) (event.getX() - mHandleLayout.getLeft());
int clickY = (int) (event.getY() - mHandleLayout.getTop());
if (isAnyClickableChildHit(mHandleLayout, clickX, clickY))
return false;
}
return super.onInterceptTouchEvent(event);
}
private boolean isAnyClickableChildHit(ViewGroup viewGroup, int clickX, int clickY) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View childView = viewGroup.getChildAt(i);
if (TAG_CLICK_INTERCEPTED.equals(childView.getTag())) {
childView.getHitRect(mHitRect);
if (mHitRect.contains(clickX, clickY))
return true;
}
if (childView instanceof ViewGroup && isAnyClickableChildHit((ViewGroup) …
Run Code Online (Sandbox Code Playgroud) android ×10
listview ×3
intentfilter ×2
textview ×2
custom-font ×1
eclipse ×1
focus ×1
m2e ×1
maven ×1
memory-leaks ×1
scrollview ×1
touch ×1
typeface ×1