设置片段重叠的地图片段
Map fragment with Setting fragment Overlaps
我的屏幕上有 google 地图,我想在带有设置按钮的导航抽屉中打开“设置”页面。但是你可以看到有一个重叠的位置。此外,如果我按下后退按钮,而不是支持地图屏幕,应用程序正在退出。不要回到主屏幕。
我正在使用文档代码:
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
...
}
在我的 Activity
中有一个按钮点击侦听器代码
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
这也是地图片段
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(map);
mapFragment.getMapAsync(this);
文档说:
If you're developing for Android 3.0 (API level 11) and higher, you
should use a PreferenceFragment to display your list of Preference
objects. You can add a PreferenceFragment to any activity—you don't
need to use PreferenceActivity.
所以我想对片段使用设置我不想用 activity
更改片段
[SOLVED]
在 Keerthivasan 的帮助下。结果代码是这样的并且工作正常
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.addToBackStack("map") //new added
.commit();
也在 PreferenceFragment 中添加
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
view.setBackgroundColor(Color.WHITE);
return view;
}
问题是,添加了背景透明的片段,所以将背景设置为片段布局。它将解决问题 :-) 官方 Docs For Back Stack Manager.. 你可以在 Whosebug 本身找到 N - 个例子。
我的屏幕上有 google 地图,我想在带有设置按钮的导航抽屉中打开“设置”页面。但是你可以看到有一个重叠的位置。此外,如果我按下后退按钮,而不是支持地图屏幕,应用程序正在退出。不要回到主屏幕。
我正在使用文档代码:
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
...
}
在我的 Activity
中有一个按钮点击侦听器代码// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
这也是地图片段
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(map);
mapFragment.getMapAsync(this);
文档说:
If you're developing for Android 3.0 (API level 11) and higher, you should use a PreferenceFragment to display your list of Preference objects. You can add a PreferenceFragment to any activity—you don't need to use PreferenceActivity.
所以我想对片段使用设置我不想用 activity
更改片段[SOLVED]
在 Keerthivasan 的帮助下。结果代码是这样的并且工作正常
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.addToBackStack("map") //new added
.commit();
也在 PreferenceFragment 中添加
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
view.setBackgroundColor(Color.WHITE);
return view;
}
问题是,添加了背景透明的片段,所以将背景设置为片段布局。它将解决问题 :-) 官方 Docs For Back Stack Manager.. 你可以在 Whosebug 本身找到 N - 个例子。