当我为我的工厂设置颜色时,它看起来像这样:
我的布局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)
我想要的正确行为是:
Fragment A -> Fragment B -> Fragment C -> Fragment A
Run Code Online (Sandbox Code Playgroud)
我目前所做的:
popBackStack()
still 这里一切顺利。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
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