操作栏背景显示在屏幕中间

时间:2014-01-26 15:37:51

标签: java android android-actionbar

我已更改操作栏的背景但看起来像这样:

(我无法发布图片,因为我没有超过10个声誉)

我有股票操作栏,我的操作栏背景显示在屏幕中间。我不知道如何更好地描述它。

你知道这是什么问题吗?

这是我的styles.xml:

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

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.


    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.


        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

    <style name="ButtonBar">
        <item name="android:paddingLeft">2dp</item>
        <item name="android:paddingTop">5dp</item>
        <item name="android:paddingRight">2dp</item>
        <item name="android:paddingBottom">0dp</item>
        <item name="android:background">@android:drawable/bottom_bar</item>
    </style>

    <style name="ActionBar" parent="AppTheme">
        <item name="android:background">@drawable/action_bar</item>
    </style>

</resources>

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.geniboys.sosyaaal"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.geniboys.sosyaaal.loginActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.geniboys.sosyaaal.DisplayMessageActivity"
            android:label="@string/title_activity_display_message"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.geniboys.sosyaaal.SignUpActivity"
            android:label="@string/title_activity_sign_up"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.geniboys.sosyaaal.SignUp2"
            android:label="@string/title_activity_sign_up2"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.geniboys.sosyaaal.LogoActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/title_activity_logo"
            android:theme="@style/FullscreenTheme"
            android:screenOrientation="portrait" >
        </activity>
    </application>

</manifest>

和layout.xml

<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    android:background="@drawable/loginbackground"
    tools:context=".loginActivity" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="22dp"
        android:layout_toLeftOf="@+id/textView1"
        android:text="@string/loginEmail"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#ffffff" />


    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView2"
        android:layout_marginTop="16dp"
        android:layout_toLeftOf="@+id/textView1"
        android:text="@string/loginSifre"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#ffffff" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView2"
        android:layout_alignLeft="@+id/textView1"
        android:ems="10"
        android:inputType="textEmailAddress"
        android:text="@string/loginEmailhint"
        android:textColor="#ffffff" >

    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView3"
        android:layout_alignLeft="@+id/editText1"
        android:ems="10"
        android:inputType="textPassword"
        android:textColor="#ffffff" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView3"
        android:layout_marginTop="26dp"
        android:layout_toRightOf="@+id/textView3"
        android:text="@string/loginGiris"
        android:textColor="#ffffff" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_toRightOf="@+id/button1"
        android:onClick="kayitOl"
        android:text="@string/loginKayit"
        android:textColor="#ffffff" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/loginSenKimsin"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

您的操作栏样式可能没有被使用,因为您的主题没有链接到它,ActionBar样式的父级也应该更改:

在AppBaseTheme中添加:

  <item name="android:actionBarStyle">@style/ActionBar</item>

将操作栏样式声明更改为:

  <style name="ActionBar" parent="android:Widget.ActionBar">

然后发布您的布局xml,我们会看看我们是否可以为您提供进一步的帮助