我想要实现的目标
谷歌在其日历应用中实施的小/大屏幕行为.
例如,当您创建新事件时,在大屏幕上会打开"对话框"
在纵向模式下,对话框工具栏的底部与活动的"扩展"工具栏的底部对齐.
上下文操作栏(例如用于文本选择)是在活动的工具栏上绘制的,并向下推动对话框,因此它不再与活动的工具栏相关联.
在横向模式下,它似乎固定在通知栏下方; 上下文操作栏是在活动的工具栏上绘制的
在小屏幕上
到目前为止我尝试过的
A.从android文档中全屏显示DialogFragment示例(不能再添加缺少声誉的b/c链接)
B.添加(感谢stackoverflow上的一些帖子)
对话框片段样式:
setStyle(DialogFragment.STYLE_NORMAL, R.style.MyDialogFragmentStyle);
<style name="MyDialogFragmentStyle" parent="@style/MyTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowIsFloating">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)删除了窗口标题
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)添加了自定义工具栏
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:homeAsUpIndicator="@drawable/ic_arrow_back_white_24dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar" >
</FrameLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)并在小型设备上将对话框设置为全屏
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
Run Code Online (Sandbox Code Playgroud)这有点工作,它解决了我想要达到的一些要点和A.'Android样本'问题(透明背景,...)
使背景中的活动变暗
工具栏始终位于同一位置,并且永远不会被屏幕键盘推出视图
在纵向模式下,对话框工具栏的底部与Activity的"扩展/大"工具栏的底部对齐.上下文操作栏(例如用于文本选择)是在活动的工具栏上绘制的,并向下推动对话框,因此它不再与活动的工具栏相关联.
在横向模式下,它似乎固定在通知栏下方; 上下文操作栏是在活动的工具栏上绘制的.
我有一个读取文件并将其内容作为a返回的方法std::string.我使用return std::string来编译OpenGL程序.在某些情况下,由于一个或两个着色器部分(读取文件内容),链接失败(编译的顶点着色器已损坏.)NULL.
为什么它表现不同,哪里是我的错?
将cout在年底始终打印正确的文件内容:
std::string read_file(const char* filePath) {
std::string content;
std::ifstream stream(filePath, std::ios::in);
if (stream.is_open()) {
std::string line = "";
while(getline(stream, line)) {
content += "\n" + line;
}
}
std::cout << "read_file " << content << "end read_file" << std::endl; // always prints the correct content
return content; // makes a copy, don't like that, unless RVO?..
}
Run Code Online (Sandbox Code Playgroud)
该fragmentSource和或vertextSource有时是空的:
GLuint fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
GLuint vertexShaderID …Run Code Online (Sandbox Code Playgroud)