没有标题栏Android主题
在我的应用程序中,我想使用Theme.NoTitleBar,但另一方面,我也不想失去Android操作系统的内部主题。。我在网上搜索,找到了以下答案。。我已经修改了my styles.xml并添加了以下代码行 内部值/styles.xml没有标题栏Android主题,android,android-layout,android-theme,Android,Android Layout,Android Theme,在我的应用程序中,我想使用Theme.NoTitleBar,但另一方面,我也不想失去Android操作系统的内部主题。。我在网上搜索,找到了以下答案。。我已经修改了my styles.xml并添加了以下代码行 内部值/styles.xml <style name="Theme.Default" parent="@android:style/Theme"></style> <style name="Theme.NoTitle" parent="@android:sty
<style name="Theme.Default" parent="@android:style/Theme"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
<style name="Theme.Default" parent="@android:style/Theme.Holo"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen"></style>
<style name="Theme.Default" parent="@android:style/Theme.Holo.Light"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.Light.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"></style>
但是当我尝试运行代码时,应用程序中的图像变得模糊。。但当我使用以下标记时:
android:theme="@android:style/Theme.NoTitleBar"
或
或
应用程序中的图像格式正确。。。但在这种情况下,我失去了新安卓操作系统的所有主题
请帮助我如何在不丢失图像和本机主题的情况下使用NoTitleBar主题
布局的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<include
android:id="@+id/main_top_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/top_bar_title" />
<RelativeLayout
android:id="@+id/container_bar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/main_top_bar"
android:layout_marginTop="-3dp"
android:background="@drawable/tab_nav_bar" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/container_bar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/container_bar1"
android:background="@drawable/location_nav_bar" >
<TableLayout
android:id="@+id/map_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:paddingBottom="5dp"
android:background="@drawable/map_bar_bg" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/MapPointer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:background="@drawable/map_pointer" />
<TextView
android:id="@+id/MapSeperator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:text="|"
android:textColor="#979ca0"
android:textSize="20dp" />
<com.pnf.myevent.CustomTextView
android:id="@+id/DisplayLocation"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="5dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#adabad"
android:textSize="12dp" />
<Button
android:id="@+id/RefreshBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:background="@drawable/refresh_button" />
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/calendar_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/MonthBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/month_button" />
<Button
android:id="@+id/TodayBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/today_button" />
<Button
android:id="@+id/WeekBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/week_button" />
</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/container_bar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/container_bar2"
android:background="@drawable/cal_nav_bar" >
<Button
android:id="@+id/CalPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="5dp"
android:background="@drawable/left_arrow_button" />
<com.pnf.myevent.CustomTextView
android:id="@+id/CalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:shadowColor="#ffffff"
android:shadowDx="0"
android:shadowDy="2"
android:shadowRadius="1"
android:text="Title"
android:textColor="#666666"
android:textSize="15dp" />
<Button
android:id="@+id/CalNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginTop="5dp"
android:background="@drawable/right_arrow_button" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/container_bar4"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@+id/container_bar3"
android:background="#c8c9cc" >
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:horizontalSpacing="2dp"
android:listSelector="#00000000"
android:numColumns="7"
android:stretchMode="columnWidth"
android:verticalSpacing="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/footer_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/container_bar4" >
<ListView
android:id="@+id/CalendarList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="#00000000"
android:cacheColorHint="#00000000"
android:divider="#dedede"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false" />
</RelativeLayout>
如果您希望保留Ui的原始样式,并且删除标题栏而不受影响,则必须删除活动中的标题栏,而不是清单。保留清单中的原始主题样式,并在每个不需要标题栏的活动中使用
this.requestWindowFeature(Window.FEATURE\u no\u title)在setcontentview()
之前的oncreate()
方法中的code>,如下所示:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_signup);
...
}
你为什么要改变android操作系统的内置主题
根据您的活动要求,您必须以这种方式实施
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
根据@arianoo
所述,您必须使用此功能
我认为这是隐藏标题栏主题的更好方法。要隐藏操作栏,请在值/样式中添加以下代码
this.requestWindowFeature(getWindow().FEATURE_NO_TITLE);
<style name="CustomActivityThemeNoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
假的
真的
然后在AndroidManifest.xml文件中,在所需的活动中添加以下代码
<activity
android:name="com.newbelievers.android.NBMenu"
android:label="@string/title_activity_nbmenu"
android:theme="@style/CustomActivityThemeNoActionBar">
</activity>
在清单中使用:-
android:theme="@style/AppTheme" >
在styles.xml中:-
假的
真的
令人惊讶的是,这与您的愿望一样有效,在AppTheme中使用相同的AppBaseTheme父级却没有。使用android:theme=“@android:style/Theme.NoTitleBar
在清单文件的应用程序标记中删除整个应用程序的标题栏,或将其放入活动标记中从单个活动屏幕删除标题栏 在styles.xml中,修改样式“AppTheme”,如
假的
真的
没有设置标题栏,您不会失去Android主题。您的XML布局有问题。请张贴布局,以便我们可以审查。所有Android平台版本都会发生这种情况吗?或者只是一个特定的问题,它发生在所有平台上。我已经创建了红色文件夹中的layout文件夹,如layout ldpi、layout mdpi、layout hdpi和layout xhdpi,还创建了包含不同屏幕的不同图像的可绘制文件夹。屏幕截图是从galaxy s3拍摄的,但同样是在模拟器上拍摄的。你能发布其中一个布局吗?除非你有特殊情况,否则你不需要基于dpi的不同布局。@JaySoyer我已经编辑了这篇文章,请看一下……好的。我的下一个问题是,您是否正在使用drawable mdpi、drawable hdpi等。XML专门用于哪种布局?这是可行的,但这不是最好的解决方案,标题栏闪烁了几秒钟,然后才为我打开。vot upI严格按照相同的顺序使用了相同的行,但我得到了一个例外:“android.util.AndroidRuntimeException:requestFeature()必须在添加内容之前调用”-有人知道为什么吗?会像这样“更正确:requestWindowFeature”(android.view.Window.FEATURE_NO_TITLE);
“android:windowActionBar”需要API+11,所以由于我的兼容性是+8,“android:windowNoTitle”成功了,谢谢;)惊喜惊喜惊喜,本页面对我来说毫无用处。我想我应该停止扩展ActionBarActivity
而支持香草活动
。甚至像requestWindowFeature(Window.FEATURE\u NO\u TITLE)这样的粗野的乱七八糟的东西代码>简单FC。这不会也会将主题修改为旧式主题吗?
<style name="CustomActivityThemeNoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<activity
android:name="com.newbelievers.android.NBMenu"
android:label="@string/title_activity_nbmenu"
android:theme="@style/CustomActivityThemeNoActionBar">
</activity>
android:theme="@style/AppTheme" >
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>