小编Jon*_*n I的帖子

浮动动作按钮方形

当我为我的工厂设置颜色时,它看起来像这样:

在此输入图像描述

我的布局xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_add"
    android:layout_marginRight="20dp"
    app:fabSize="normal"
    android:elevation="@dimen/fab_elevation"
    android:background="#000000"
    android:stateListAnimator="@animator/fab_anim"
    android:layout_gravity="center_horizontal"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true" />
Run Code Online (Sandbox Code Playgroud)

颜色也不会改变.谁能帮我理解我做错了什么?

我也尝试了一个@color链接,但它崩溃了,一个drawable的背景(ex. android:background="@drawable/fab_background")没有任何反应.

这是可绘制的 fab_background.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <ripple android:color="@color/fab_color_1_muted">
        <item>
            <shape>
                <solid android:color="@color/fab_color_1" />
            </shape>
        </item>
    </ripple>
</item>
Run Code Online (Sandbox Code Playgroud)

android action button floating floating-action-button

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

从管理器中删除片段时,fragmentManager.getBackStackEntryCount() 不会减少

我想要的正确行为是:

Fragment A -> Fragment B -> Fragment C -> Fragment A
Run Code Online (Sandbox Code Playgroud)

我目前所做的:

  1. 当我想从 B 返回到 A 时,我使用popBackStack()still 这里一切顺利。
  2. 当我想从 B 转到 CI 时,删除 B 并添加 C。(Fragments 数量为 2,backStackEntryCount 数量为 3,替换相同)。
  3. 当我想从 C 返回到 A 时,我可以使用, popBackStack()但 BackStackEntryCount 仍将包含 B 的条目。

我真的需要backStackEntryCount与管理器中包含的片段相同。

有人知道我做错了什么吗?

我的代码:

        Fragment fragment1 = fragmentManager.findFragmentByTag("NavigationFragment_");
    if (fragment1 != null) {
        fragmentManager.beginTransaction()
                .setTransition(TRANSIT_FRAGMENT_FADE)
                .remove(fragment1)
                .commit();

    }

    fragmentManager.beginTransaction()
            .addToBackStack(backstack)
            .setTransition(TRANSIT_FRAGMENT_OPEN)
            //.remove(getFragmentManager().findFragmentByTag(NavigationFragment_.class.getSimpleName()))
            .add(R.id.fragmentContainer, fragment, fragment.getClass().getSimpleName())
            .commit();
Run Code Online (Sandbox Code Playgroud)

我一直在寻找解决方案,但没有结果,所以请不要将此标记为重复。

提前致谢。

java android android-fragments fragmentmanager fragment-backstack

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

Service stopForeground(false) remove notification when should not

Instead of

stopForeground(true)

calling,

stopForeground(false)

should retain the notification as it is (without ongoing state) unless it is dismissed by user/removed programmatically. This also should prevents notification flashing since I am not recreating the notification.

But it does not work. stopForeground(false) has the same behavior of stopForeground(true).

This is a sample project:

public class AudioTestService extends Service {
private static final String CHANNEL_ID = "TestChannel";
private static final int NOTIFICATION_ID = 14;
Notification mBuilder;

public AudioTestService() {
}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

service android android-notifications foregroundnotification foreground-service

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