小编iGi*_*o90的帖子

在Android中检查颜色是暗还是亮

根据标题,我的问题是:Android是否提供任何方式来分析/确定颜色(显然是动态的)是亮还是暗?

android background colors

46
推荐指数
4
解决办法
1万
查看次数

Android:2相对布局分为半屏

我多次尝试绘制2个相对布局水平对齐并分为半屏.

在此输入图像描述

我用油漆设计图像来更好地解释我的意思.

有什么建议吗?

android android-layout android-relativelayout

39
推荐指数
3
解决办法
7万
查看次数

在Android Window上获取活动标志

是否有可能以编程方式获取Window上当前处于活动状态的标志?

我们可以启用标志:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
Run Code Online (Sandbox Code Playgroud)

api是否提供了获取当前活动标志列表的方法?谢谢

flags android window-managers window

22
推荐指数
1
解决办法
8174
查看次数

PendingIntent启动和停止服务

我试图与一个按钮一个简单的小工具,开始ServiceOnClickPendingIntent().我可以开始很好,但我无法找到一种方法来阻止它(我知道我可以用一个BroadcastReceiver或类似的东西,但我想避免硬编码).

这是我的代码:

        Intent intent = new Intent(context, myService.class);
        PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);

        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.my_widget);

        if (!ismyserviceup(context)) {
            views.setOnClickPendingIntent(R.id.my_button, pendingIntent);
        } else {
            // i need to stop it!!!!
        }
Run Code Online (Sandbox Code Playgroud)

android android-widget android-service android-pendingintent

10
推荐指数
1
解决办法
1万
查看次数

onClick:在Facebook上分享图片

我想在我的新网站上启动Facebook共享器的图像上设置一个onClick功能.

以下是一些可能有助于理解我所说的内容的代码

<div id="mImageBox">
<img id='my_image' src='' width="auto" height="auto"/>
</div>
Run Code Online (Sandbox Code Playgroud)

图像src是空白的,因为它是由另一个JavaScript函数通过使用"my_image"注入的

所以,我尝试使用此方法设置onClick函数:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script>

<div id="mImageBox">
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank"><img id='my_image' src='' width="auto" height="auto"/></a>
</div>
Run Code Online (Sandbox Code Playgroud)

onClick函数运行良好,但它链接到img所在的页面而不是img本身!

你有什么建议吗?

javascript css image onclick

9
推荐指数
2
解决办法
4万
查看次数

Android视图扩展了动画

我正在尝试编辑这些源代码以创建一个可以处理我所有视图的简单函数.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

RelativeLayout mLayout1 = (RelativeLayout) findViewById(R.id.layout1);
RelativeLayout mLayoutToBeExpanded1 = (RelativeLayout) findViewById(R.id.layout_exp_1);
addAction(mLayout, mLayoutToBeExpanded);

RelativeLayout mLayout2 = (RelativeLayout) findViewById(R.id.layout2);
RelativeLayout mLayoutToBeExpanded2 = (RelativeLayout) findViewById(R.id.layout_exp_2);
addAction(mLayout2, mLayoutToBeExpanded2);

RelativeLayout mLayout3 = (RelativeLayout) findViewById(R.id.layout3);
RelativeLayout mLayoutToBeExpanded3 = (RelativeLayout) findViewById(R.id.layout_exp_3);
addAction(mLayout3, mLayoutToBeExpanded3);

}

    public void addAction(final View layout, final View summary) {

    summary.getViewTreeObserver().addOnPreDrawListener(
            new ViewTreeObserver.OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    summary.getViewTreeObserver().removeOnPreDrawListener(this);
                    summary.setVisibility(View.GONE);

                    final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
                    final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); …
Run Code Online (Sandbox Code Playgroud)

android onclick android-animation android-layout

5
推荐指数
1
解决办法
1万
查看次数

在android中获取ActionBar TextView(标题)

根据标题,我需要检索出现在ActionBar中的活动标题的textview.我可以使用以下方法获取ActionBar视图:

private View getActionBarView() {
    View v = mWindow.getDecorView();
    int resId = getResources().getIdentifier("action_bar_container", "id", "android");
    return v.findViewById(resId);
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道TextView的id,所以我可以在actionbar视图中找到ViewById?

解决了:好吧,我用相同的方法解决了但是通过改变id:

private TextView getActionBarTitle() {
    View v = mWindow.getDecorView();
    int resId = getResources().getIdentifier("action_bar_title", "id", "android");
    return v.findViewById(resId);
}
Run Code Online (Sandbox Code Playgroud)

android android-actionbar

3
推荐指数
1
解决办法
6834
查看次数

Android中的ApplicationInfo适配器仅显示具有启动器意图的应用程序

根据标题,我正在寻找一个解决方案,只显示具有启动器意图的应用程序.这是我检索应用列表的代码:

public static List<ApplicationInfo> getInstalledApplication(Context context) {
    PackageManager packageManager = context.getPackageManager();
    List<ApplicationInfo> apps = packageManager.getInstalledApplications(0);
    Collections.sort(apps, new ApplicationInfo.DisplayNameComparator(packageManager));
    return apps;
}
Run Code Online (Sandbox Code Playgroud)

是否可以添加规则以删除没有启动器意图的所有包?谢谢

android android-adapter android-applicationinfo

2
推荐指数
1
解决办法
1372
查看次数