动作栏显示在android studio的显示屏中,但未显示在我的实际应用中 [英] Action bar shown in display of android studio but not in my actual app

查看:70
本文介绍了动作栏显示在android studio的显示屏中,但未显示在我的实际应用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我有一个包含两个活动的应用程序,在第二个活动中,我有一个操作栏,显示的应用程序标题没有问题. 但是在我的启动器活动中,该栏显示在android studio显示屏中,而不显示在实际应用中... 知道发生了什么事吗? 这是我的xml:

Hey guys i have an app with two activities, in the second activity i have an action bar with the title of my app displayed without problem. However in my launcher activity the bar is shown in android studio display but not in the actual app... Any idea whats happening ? Here is my xml :

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
    tools:context=".Menu_Activity">

<ListView
    android:id="@+id/list"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_weight="0.99"
    android:dividerHeight="2px">

</ListView>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" />

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Download content"
    android:textColor="#FFFFFF"
    android:id="@+id/button"
    android:background="@drawable/buttonshape" />

 </LinearLayout>

这是显示栏的xml:

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">



<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"

    />

<ListView
    android:id="@+id/list"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:divider="#FF000080"
    android:dividerHeight="2px">


</ListView>



 </LinearLayout>

除了在两种情况下都扩展AppCompatActivity之外,我对Java文件中的栏没有做任何事情.

Im not doing anything concerning the bar in the java files except extending AppCompatActivity in both cases.

这是样式文件:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>



<style name="AppTheme.AppBarOverlay"     parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

谢谢您的帮助.

推荐答案

可能性1: 如果您的应用扩展了Activity,请将其更改为AppCompatActivity.

Possibility 1: If your app extends Activity change it to AppCompatActivity.

可能性2: 您确定没有名为"styles.xml"的不同版本的不同文件吗?确保它们都没有名为AppTheme.NoActionBar的主题.

Possibility 2: Are you sure you don't have different files of different versions named "styles.xml"? Make sure that none of the them have a theme named AppTheme.NoActionBar.

您正在运行该应用的设备将为其版本获取更合适的主题.例如,如果您有一个名为styles.xml(v21)的文件,则Lollipop或更高版本的设备将使用该文件.

The device you are running the app will fetch the more adequate theme for its version. If you have a file named styles.xml(v21) for example, devices with Lollipop or above will use it.

这篇关于动作栏显示在android studio的显示屏中,但未显示在我的实际应用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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