没有标题栏的Andr​​oid主题 [英] No Title Bar Android Theme

查看:101
本文介绍了没有标题栏的Andr​​oid主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想使用Theme.NoTitleBar,但另一方面,我也不想失去对Android操作系统的内部主题。我在网上搜索,发现如下的回答。我已经修改了我的styles.xml并加入了$以下线c $ C ..

In my application I want to use the Theme.NoTitleBar, but on the other hand I also don't want to loose the internal Theme of the Android OS.. I searched on the net and Found the following answer.. I have modified my styles.xml and added the following line of code..

在值/ styles.xml

Inside values/styles.xml

<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>

里面的值-V11 / styles.xml

Inside values-v11/styles.xml

<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>

里面的值-V14 / styles.xml

Inside values-v14/styles.xml

<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>

应用程序清单文件的标签我添加的属性:

In the application tag of the Manifest file I have added an attribute of:

android:theme="@style/Theme.NoTitle"

但是,当我尝试运行C图像中的$ C $在我的应用程序变得模糊。但是,当我用下面的标记:

But when I try to run the code The images in my application gets Blurry.. But when I use the following tag:

android:theme="@android:style/Theme.NoTitleBar"

android:theme="@android:style/Theme.Light.NoTitleBar"

android:theme="@android:style/Theme.Black.NoTitleBar"

在应用程序中拍摄的图像以正确形式。但是在这种情况下,我失去了全新的Andr​​oid OS上的所有主题。

The images in the application comes in the correct form... But In this case I lose all the themes on the new Android OS..

请帮助我,我该如何使用NoTitleBar主题没有松动的图像和本土主题。

Please help me how can I use NoTitleBar Theme without loosing the Images and the Native Theme..

code的布局:

<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>

推荐答案

如果你希望你的用户界面的原有风格保持和标题栏上没有任何影响被删除,你必须删除标题栏在你的活动而不是清单。离开你的清单,并在您要没有标题栏使用 this.requestWindowFeature(Window.FEATURE_NO_TITLE)每项活动有原始的主题风格; 的OnCreate()方法之前 的setContentView()是这样的:

if you want the original style of your Ui to remain and the title bar to be removed with no effect on that, you have to remove the title bar in your activity rather than the manifest. leave the original theme style that you had in the manifest and in each activity that you want no title bar use this.requestWindowFeature(Window.FEATURE_NO_TITLE); in the oncreate() method before setcontentview() like this:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_signup);
    ...
}

这篇关于没有标题栏的Andr​​oid主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆