yan*_*nko 25 android fullscreen title
有没有办法隐藏窗口标题,以便它不会以全屏模式显示(
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN,
LayoutParams.FLAG_FULLSCREEN)
Run Code Online (Sandbox Code Playgroud)
)但随后会出现
getWindow().clearFlags(LayoutParams.FLAG_FULLSCREEN)
Run Code Online (Sandbox Code Playgroud)
?
requestWindowFeature(Window.FEATURE_NO_TITLE)
Run Code Online (Sandbox Code Playgroud)
当然不是一个选择,因为这不会让它回来.
snc*_*tln 57
我在Android游戏中处理这个问题的方法是在我的Activity的onCreate()中调用以下行
requestWindowFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)
然后,我可以在我的activity类中使用以下代码关闭全屏功能(通常从菜单选项调用)(m_contentView变量是来自findViewById()的视图,使用您在调用setContentView()时使用的id你的创造)
private void updateFullscreenStatus(boolean bUseFullscreen)
{
if(bUseFullscreen)
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
m_contentView.requestLayout();
}
Run Code Online (Sandbox Code Playgroud)
我在所有游戏中都使用这种技术而没有任何问题.
为什么这么说
requestWindowFeature(Window.FEATURE_NO_TITLE); 当然不是一个选择
?
::编辑::
好吧,如果你想在活动的生命周期中动态显示和隐藏它,我不确定你是否可以使用正式的窗口标题来做到这一点,因为已经提到过关于需要在setContentView()之前设置的窗口特征的注释叫(链接)
你可以做的一件事是实现你自己的标题栏并动态显示和隐藏...我把这个例子放在一起,应该让你在正确的轨道上
这是布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fadingEdgeLength="0sp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitleBarLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/myTitleBarTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:paddingTop="4dip"
android:paddingBottom="4dip"
android:paddingLeft="6dip"
android:textStyle="bold"
android:shadowColor="#BB000000"
android:shadowRadius="3.0"
android:shadowDy=".25"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#CCEEEEEE"
android:padding="10dip"
/>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<!-- Insert your regular layout stuff here -->
<Button android:id="@+id/toggle_title_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toggle Title"
/>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这里是主要活动的代码,允许您打开和关闭我们的自定义标题栏
package com.snctln.test.HelloGridView;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
public class HelloGridView extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)this.findViewById(R.id.myTitleBarTextView);
tv.setBackgroundColor(0xFF848284);
tv.setTextColor(0xFFFFFFFF);
Button toggleTitleButton = (Button)this.findViewById(R.id.toggle_title_button);
toggleTitleButton.setOnClickListener( new OnClickListener()
{
@Override
public void onClick(View v)
{
LinearLayout ll = (LinearLayout)findViewById(R.id.myTitleBarLayout);
if(ll.getVisibility() == View.GONE)
{
ll.setVisibility(View.VISIBLE);
}
else
{
ll.setVisibility(View.GONE);
}
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
它看起来并不完美,但您可以随时使用布局来做到这一点.
替代文字http://i39.tinypic.com/120sfp1.png
我的另一个想法是,如果你只想隐藏所有内容以显示进度条,为什么不使用ProgressDialog?
这个类很容易使用......
progressDlg = ProgressDialog.show(context, getString(R.string.progress_dialog_title_prepare), getString(R.string.progress_dialog_body_prepare));
// do long running operation
if(operationFailed)
{
progressDlg.cancel();
}
else
{
progressDlg.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
小智 11
禁用应用程序的标题(它是应用程序名称)
requestWindowFeature(Window.FEATURE_NO_TITLE)
Run Code Online (Sandbox Code Playgroud)
要禁用顶部的通知栏(因此请求Android应用程序管理器允许全屏)
getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN)
希望这有助于任何想要了解差异的人!
Dav*_*vid 10
if(useFullscreen)
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Run Code Online (Sandbox Code Playgroud)
这对我有用..在onResume方法
| 归档时间: |
|
| 查看次数: |
61151 次 |
| 最近记录: |