小编gmm*_*mmo的帖子

setRangeNotifier(RangeNotifier)已被弃用?

我正在使用alt.beacon库,现在我收到此警告:

warning: [deprecation] setRangeNotifier(RangeNotifier) in BeaconManager has been deprecated.
Run Code Online (Sandbox Code Playgroud)

但更换的是什么?我需要对区域中的信标进行测距,并且回调RangeNotifier对于实现此功能至关重要.

public interface RangeNotifier {
    void didRangeBeaconsInRegion(Collection<Beacon> var1, Region var2);
}
Run Code Online (Sandbox Code Playgroud)

任何人都有一个新库如何工作的样本?

谢谢!

android deprecation-warning altbeacon

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

GridLayout超出范围

我试图用GridLayout重现这个计算器布局

在此输入图像描述

但这是我尝试的代码所得到的.

在此输入图像描述

实际上在设备上它变得更糟,它会削减必须跨越两行的最后一个相等按钮.

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:columnCount="5"
    android:rowCount="2"
    android:orientation="horizontal"
    android:padding="5dp">

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="1" />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="2" />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="3" />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="-" />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="2"
        android:layout_gravity="fill_vertical"
        android:text="=" />


    <Button
        android:layout_columnSpan="2"
        android:layout_rowSpan="1"
        android:layout_gravity="fill_horizontal"
        android:text="0" />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="." />

    <Button
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="+" />

    <Space
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="-" />

    <Space
        android:layout_columnSpan="1"
        android:layout_rowSpan="1"
        android:text="=" />

</GridLayout>
Run Code Online (Sandbox Code Playgroud)

然而,它一直走出界限.我试图根据这个帖子改为"android.support.v7.widget.GridLayout":

GridLayout列超出了它的范围

但没多大帮助.

任何线索如何使其精确匹配手机大小?

android android-gridlayout

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

在滚动视图中嵌套框架布局?

我遇到了一个问题,我不确定解决它的最佳方法。我需要在滚动视图中包含所有小部件。

下面是布局,我使用了框架布局,因为我需要重叠一堆图像。然而,整个框架布局不能在滚动视图内。但我需要滚动整个面板。用黄色箭头标记的部分显示了框架布局。

在此处输入图片说明

我看了这个帖子,但这不是我想要的。

ScrollView 内部 ScrollView

这是xml,如果有人可以提供线索,我将不胜感激。谢谢!

<!-- unfortunately I cannot put this inside the scrollview :( -->
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/image_background"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@drawable/follow_add" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="100dp"
        android:gravity="center|bottom"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/image_icon"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:background="@drawable/feed_active" />
    </LinearLayout>

    <ImageView
        android:id="@+id/dismiss"
        android:layout_gravity="left"
        android:layout_margin="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/close_messages_modal" />
    <ImageView
        android:id="@+id/follow"
        android:layout_gravity="right"
        android:layout_margin="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/follow_add" />
</FrameLayout>


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10dp"
            android:text="Layout above needs to scroll"
            android:textColor="@color/half_dark_text_color"
            android:textSize="28sp"
            android:textStyle="bold" /> …
Run Code Online (Sandbox Code Playgroud)

android scrollview android-framelayout

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

点击android通知图标不会触发广播接收器

我有一个与推送通知挂钩的应用程序.当用户点击通知时,我希望触发广播接收器而不是活动.

我看了这些线程,看起来这是完全可能和常见的.

未触发Android通知操作(PendingIntent)

通知点击发送广播

但是我无法让它发挥作用.我看到了通知,但是当我点击它时它从未触发我的广播接收器.

在这里我尝试过:

  1. 我创建了一个自定义接收器

    public class NotificationOnClickReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(final Context context, Intent intent) {
            Log.d(Constants.Engine.LOGGER_TAG_GCM,
                    NotificationOnClickReceiver.class.toString() + " triggered");
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 我在我的全局应用程序(非活动)上动态注册了此接收器

    mNotificationOnClickReceiver = new NotificationOnClickReceiver();
    IntentFilter intentFilterOnClick = new IntentFilter(Constants.Engine.BROADCAST_RECEIVER_FILTER_NOTIFICATION_ONCLICK);
    getApplicationContext().registerReceiver(mNotificationOnClickReceiver, intentFilterOnClick);
    Log.e(Constants.Engine.LOGGER_TAG_DBG, "mNotificationOnClickReceiver = " + mNotificationOnClickReceiver.toString());
    
    Run Code Online (Sandbox Code Playgroud)

过滤器只是一个字符串常量(我想知道这是不是问题)

    public static final String BROADCAST_RECEIVER_FILTER_NOTIFICATION_ONCLICK = "push_notification.onclick";
Run Code Online (Sandbox Code Playgroud)
  1. 接收方意图设置:

    // When the user taps on the notification bar, this is the receiver that I want to be called
    Intent pushNotificationIntent;
    Log.e(Constants.Engine.LOGGER_TAG_DBG, "Notification called!"); …
    Run Code Online (Sandbox Code Playgroud)

notifications android push-notification android-intent android-pendingintent

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

无法使用 PIL 和 python 2.7 将文本写入灰度 PNG

我正在尝试使用 PIL 并按照此线程在灰度 png 上写一些文本。这看起来很简单,但我不确定我做错了什么。

使用 PIL 在图像上添加文本

然而,当我尝试这样做时,draw.text函数就死了:

from PIL import Image, ImageDraw, ImageFont
img = Image.open("test.png")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("open-sans/OpenSans-Regular.ttf", 8)
# crashes on the line below:
draw.text((0, 0), "Sample Text", (255, 255, 255), font=font)
img.save('test_out.png')
Run Code Online (Sandbox Code Playgroud)

这是错误日志:

"C:\Python27\lib\site-packages\PIL\ImageDraw.py", line 109, in _getink
ink = self.draw.draw_ink(ink, self.mode)
TypeError: function takes exactly 1 argument (3 given)
Run Code Online (Sandbox Code Playgroud)

谁能指出我的问题?

python-imaging-library python-2.7 pillow

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