[英]Android Studio Navigation bar showing Apps's name is missing?
When I launch the apps in Emulator, I realize the Navigation bar which shows apps name is missing. 当我在模拟器中启动应用程序时,我意识到导航栏显示缺少应用程序名称。 May I know what's going on? 我可以知道发生了什么事吗?
public class MainActivity extends Activity implements OnClickListener {
EditText first_name;
EditText last_name;
Button button_submit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
first_name = (EditText) findViewById(R.id.first_name);
last_name = (EditText) findViewById(R.id.last_name);
button_submit = (Button) findViewById(R.id.button_submit);
button_submit.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(this, ViewActivity.class);
intent.putExtra("first_name", first_name.getText().toString());
intent.putExtra("last_name", last_name.getText().toString());
startActivity(intent);
}
}
Manifest.xml 的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yuqk.intent_usage">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ViewActivity"></activity>
</application>
Style.xml Style.xml
<resources>
<!-- 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>
Please refer the the screenshot for reference.. Thanks! 请参考屏幕截图以供参考..谢谢!
Probably you have 可能你有
android:theme="@style/AppTheme.NoActionBar"
in your AndroidManifest.xml
. 在AndroidManifest.xml
。 If so, you need to change it to 如果是这样,您需要将其更改为
android:theme="@style/AppTheme"
(assuming you have AppTheme defined in styles.xml
with parent parent="Theme.AppCompat.Light.DarkActionBar"
or similar). (假设您在styles.xml
使用parent parent="Theme.AppCompat.Light.DarkActionBar"
或类似内容定义了parent="Theme.AppCompat.Light.DarkActionBar"
)。
Check this if you add toolbar
in xml file like this 如果您在xml文件中添加toolbar
,请检查此项
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
then add this code to your MainActivity.java
file. 然后将此代码添加到MainActivity.java
文件中。
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
and in Manifest.xml you have use this theme. 在Manifest.xml中你已经使用了这个主题。
android:theme="@style/AppTheme.NoActionBar"
styles.xml you have this styles.xml你有这个
<!-- 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.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
If you have toolbar
included in your xml, add this line of code inside of onCreate()
method, right after setContentView(R.layout.activity_main);
如果您的xml中包含toolbar
,请在setContentView(R.layout.activity_main);
之后的onCreate()
方法中添加此行代码setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
There is an option in the Layout editor named 'Show layout decorations' You must have this option turned off. 布局编辑器中有一个名为“显示布局装饰”的选项您必须关闭此选项。 There is a button with the image of an eye above the mobile screen in android studio. android studio中的移动屏幕上方有一个带有眼睛图像的按钮。 Click on that and a drop down menu should be seen. 点击它,应该看到一个下拉菜单。 Check the 'Show Layout Decorations' and your problem should be solved. 检查“显示布局装饰”,您的问题应该解决。
It might that you have changed Style.xml file with theme style of NoActionBar 您可能已更改主题样式为NoActionBar的 Style.xml文件
please change it to <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
请将其更改为<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
and then Run 然后运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.