小编Cur*_*Cat的帖子

Android:如何删除工具栏和状态栏之间的界限

我有兴趣拥有统一的彩色工具栏和状态栏.如果我提供colorPrimary并且colorPrimaryDark颜色相同,这应该是可能的.我使用ActionBar获得了所需的结果,但没有使用工具栏.我还将创建一个导航视图,所以我需要状态栏为透明.

使用工具栏 使用ActionBar

代码:Styles-v21

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

代码:样式

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>

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

重现步骤 :

  1. 在android studio中创建一个新项目 Navigation Drawer Activity
  2. 设置primaryprimaryDark颜色相同
  3. 在设备或模拟器上运行

android android-actionbar android-toolbar

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

Python 子进程 Popen.terminate() 仍然停留在 wait()

我正在尝试使用 RPi 实现无线电播放器。目标是设置播放列表并在播放列表填充后开始播放。一旦停止代码被执行,播放器和收音机进程就会退出。

无线电进程很好地终止,但播放器进程即使在调用终止后仍然保持等待。如果再次调用停止代码,则播放器进程终止

尝试的事情:

  1. 重新排序等待命令(播放器,收音机)/(收音机,播放器)
  2. 类似地重新排序终止命令
  3. 使用 kill 而不是终止挂起 RPi

玩家代码:

while playlist:
    player = subprocess.Popen(
            ["avconv", "-i", "Music/%s" % playlist[0], "-f", "s16le", "-ar", 
            "22.05k", "-ac", "1", "-"], stdout=subprocess.PIPE)

    radio = subprocess.Popen(["./pifm", "-", freq], stdin=player.stdout)

    radio.wait()
    print "************ exiting from radio :)"
    player.wait()
    print "************ exiting from player :)"

    playlist.pop(0)
player = None
radio = None
Run Code Online (Sandbox Code Playgroud)

播放器停止代码(从另一个线程调用):

print "************ stop requested"

if radio and radio.poll() is None:
    print "************ terminating radio :)"
    radio.terminate()

if player and player.poll() is None: …
Run Code Online (Sandbox Code Playgroud)

python subprocess python-multithreading raspberry-pi

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

calloc会覆盖另一个变量的内存吗?

我正在编写一个程序,image使用对源数组(hist)中存储的数据的计算来创建灰度图像().存储在源数组中的数据在调用calloc for image后重置为零.

func1(){
    float * hist = (float *) calloc(256, sizeof(float));
    // operation to populate 'hist'
    for...{
       for...{
           hist.....
       }
    }

    hist2img(hist);
    free(hist);
    return 0;
}

hist2img(hist){
    cout << "-> " << hist [4 * 250] << endl;

    unsigned char * image = (unsigned char *) calloc(256 * 256, sizeof(unsigned char));

    cout << "-> " << hist [4 * 250] << endl;

    free(image);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是:

-> 0.997291
-> 0
Run Code Online (Sandbox Code Playgroud)

数据会发生什么变化?hist在calloc指令之后,所有元素都为0.我需要image …

c c++ malloc calloc data-management

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