活动标题显示奇数值

时间:2016-05-15 09:51:22

标签: java android android-activity layout title

我有一项基于空活动的活动。我对此做了大量修改,但我没有触及活动标题。但是,我注意到标题现在显示“白色”一词。我有第二个活动,其中包含单词white作为按钮的文本和一些包含单词的字符串资源。但是,我不确定如何将这些中的任何一个作为主要活动标题显示出来。我在下面列出了一些相关部分。

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera2" android:required="false"/>

<application
    android:debuggable="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MyActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DisplayMessageActivity"></activity>
    <activity android:name=".DisplayDialogTextProperties"
              android:theme="@android:style/Theme.Dialog"/>
</application>

</manifest>

的字符串

<resources>
<string name="app_name">MyFirstApp</string>
<string name="edit_message">Enter Text</string>
<string name="button_send">Apply Text</string>
<string name="action_settings">Settings</string>
<string name="open_gallery">Open Gallery</string>
<string name="new_image">New Image</string>
<string name="OK">OK</string>
<string name="Cancel">Cancel</string>
<string name="Red">Red</string>
<string name="Blue">Blue</string>
<string name="Green">Green</string>
<string name="Black">Black</string>
<string name="White">White</string>
<string name="Yellow">Yellow</string>
<string name="Text_Properties_Colour">Choose the text colour you require</string>
<string name="Commit_Change">Commit Change</string>
<string name="Revoke_Change">Remove Change</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>

活动onCreate方法

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    packageManager = getPackageManager();
   // getActionBar().setTitle("MyFirstApp");
}
</resources>

活动布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<!--tools:context="com.example.myfirstapp.MyActivity">-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/text_bar"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="false">
    <!--app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_my"-->

    <EditText android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message"
        android:enabled="false"/>

    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"
        android:onClick="applyTextToImage"
        android:enabled="false"
        android:id="@+id/overlayButton"/>

</LinearLayout>

<LinearLayout
    android:id="@+id/buttons_Layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="false"
    android:gravity="bottom"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">

    <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/open_gallery"
            android:onClick="openGallery">
    </Button>

    <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/new_image"
            android:onClick="newImage">
    </Button>

</LinearLayout>

<FrameLayout
    android:id="@+id/image_Layout"
    android:layout_below="@id/text_bar"
    android:layout_above="@id/buttons_Layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
 >

    <ImageView
        android:id="@+id/image_View"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
/>
   <!--<TextView
        android:id="@+id/image_Overlay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textAlignment="center"
        android:textSize="25dp"
        android:textColor="#ff0000"/>-->
</FrameLayout>

</RelativeLayout>

对话框布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

<TextView
android:id="@+id/text_Properties"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/Text_Properties_Colour"/>

<Button
    android:id="@+id/choose_Blue"
    android:layout_centerHorizontal="true"
    android:layout_below="@id/text_Properties"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Blue"/>

<Button
    android:id="@+id/choose_Red"
    android:layout_toLeftOf="@id/choose_Blue"
    android:layout_below="@id/text_Properties"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Red"/>

<Button
    android:id="@+id/choose_Green"
    android:layout_below="@id/text_Properties"
    android:layout_toRightOf="@id/choose_Blue"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Green"/>

<!--<TextView
    android:id="@+id/center_Point"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/choose_Blue"
    android:layout_centerHorizontal="true"/>-->

<Button
    android:id="@+id/choose_Black"
    android:layout_below="@id/choose_Blue"
    android:layout_centerHorizontal="true"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Black"/>

<TextView
    android:id="@+id/center_Point_Lower"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/choose_Black"
    android:layout_centerHorizontal="true"/>

<Button
    android:id="@+id/CommitChanges"
    android:onClick="commit_Click"
    android:text="@string/Commit_Change"
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/choose_Black"
    android:layout_toLeftOf="@id/center_Point_Lower"/>


<Button
    android:id="@+id/choose_Yellow"
    android:layout_below="@id/choose_Blue"
    android:layout_toLeftOf="@id/choose_Black"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Yellow"/>

<Button
    android:id="@+id/choose_White"
    android:layout_below="@id/choose_Blue"
    android:layout_toRightOf="@id/choose_Black"
    android:onClick="btn_Click"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/White"/>

<Button
    android:id="@+id/CancelChanges"
    android:onClick="cancel_Click"
    android:text="@string/Revoke_Change"
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/choose_Black"
    android:layout_toRightOf="@id/center_Point_Lower"/>

</RelativeLayout>

样式

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

</resources>

1 个答案:

答案 0 :(得分:-1)

根据Artem的指示Rebuild Project。