有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android材质设计工具栏未在活动\u main中正确显示。xml

这是我的主要活动。xml

<RelativeLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:paddingLeft="@dimen/activity_horizontal_margin"
安卓:paddingRight="@dimen/activity_horizontal_margin"
安卓:paddingTop="@dimen/activity_vertical_margin"
安卓:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<安卓.support.v7.widget.Toolbar
    xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:id="@+id/tb_main"
    安卓:layout_width="match_parent"
    安卓:layout_height="wrap_content"
    安卓:minHeight="?attr/actionBarSize"
    安卓:background="?attr/colorPrimary"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</RelativeLayout>

这是我的风格。xml

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


这是主要活动。java

import 安卓.support.v7.app.ActionBarActivity;

import 安卓.os.Bundle;
import 安卓.support.v7.widget.Toolbar;
import 安卓.view.Menu;
import 安卓.view.MenuItem;

public class MainActivity extends ActionBarActivity {
    private static String TAG = "LOG";
    private Toolbar mToolbar;
    private Toolbar mToolbarBottom;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mToolbar = (Toolbar) findViewById(R.id.tb_main);
    mToolbar.setTitle("Main Activity");
    mToolbar.setSubtitle("just a Subtitle");
    mToolbar.setLogo(R.drawable.ic_media_play);
    setSupportActionBar(mToolbar);
}

在过去的两天里,我一直在努力解决这个问题。浅色工具栏未在屏幕上正确显示。安卓编程的新功能。任何建议都会大有帮助


共 (0) 个答案