某些活动中缺少操作栏

时间:2016-02-14 17:37:20

标签: java android xml

我有很多活动。现在我的问题是,操作栏存在于某些操作栏中而在其他操作栏中不存在。这是xml文件。

Styles.xml `

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

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

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

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

`

清单文件

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@drawable/icon512"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Tutorial"
        android:label="@string/title_activity_tutorial"
        android:theme="@style/AppTheme.NoActionBar" />

    <receiver android:name=".SmsListener">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
    </receiver>

    <activity
        android:name=".Friends"
        android:label="@string/title_activity_friends"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".Settings_1"
        android:label="Settings"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".LAtLong"
        android:label="Locating.."
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".About"
        android:label="@string/title_activity_about"
        android:theme="@style/AppTheme.NoActionBar" />
</application>

教程活动(存在操作栏)

<?xml version="1.0" encoding="utf-8"?>

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

<include layout="@layout/content_tutorial" />

关于活动(缺少操作栏)

<?xml version="1.0" encoding="utf-8"?>

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

<include layout="@layout/content_about" />

About.class

public class About extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ScrollView scrolView = (ScrollView)findViewById(R.id.about_scroll);

    new CountDownTimer(200000,100) {

        int i = 1;
        public void onTick(long millisUntilFinished) {

            scrolView.scrollTo((0), i);
            i++;
        }

        public void onFinish() {
        }

    }.start();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

Content_about.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background2"
android:orientation="vertical">


<ImageView
    android:id="@+id/imageView3"
    android:layout_width="100sp"
    android:layout_height="100sp"
    android:layout_gravity="center"
    android:background="@drawable/icon512" />

<TextView
    android:id="@+id/textView13"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:paddingTop="10sp"
    android:text="RebelX 1.001"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#ffffff" />

<ScrollView
    android:id="@+id/about_scroll"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="none">


    <LinearLayout
        android:id="@+id/linearLayout4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingRight="8dip">

        <TextView
            android:id="@+id/textView9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center_horizontal"
            android:inputType="textMultiLine"
            android:paddingTop="10sp"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#ffffff" />


    </LinearLayout>
</ScrollView>


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">


    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="fill_parent"
        android:layout_height="75sp"
        android:background="@drawable/codelords" />

</LinearLayout>

我错过了什么?任何帮助表示赞赏。提前谢谢。

0 个答案:

没有答案