高程不适用于android元素

时间:2019-02-26 13:11:44

标签: android android-toolbar android-button android-elevation

无论是在android studio视图中还是在设备上运行应用程序时,按钮和工具栏的高度都不适用于我的android应用程序。

所有元素都没有高程并且外观平坦。

这是我的风格定义

<resources>

<!-- Base application theme. -->
<style name="AppTheme" 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>

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

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

<style name="AppTheme.Launcher">
    <item name="android:windowBackground">@drawable/launcher_screen</item>
    <!-- Optional, on Android 5+ you can modify the colorPrimaryDark color to match the windowBackground color for further branding-->
    <!-- <item name="colorPrimaryDark">@android:color/white</item> -->
</style>

</resources> 

在带有工具栏和应该升高的按钮的活动的onCreate方法中,我具有以下

setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

   ....

在xml文件中,我有以下

  <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:textColor="@color/colorWhite"
        android:elevation="6dp"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/Theme.AppCompat.Light">

        <TextView
            android:id="@+id/gamesetup_toolbar_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="68dp"
            android:text="Sign Up"
            android:textAlignment="center"
            android:textStyle="bold"
            android:textColor="@color/colorWhite"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"/>

    </android.support.v7.widget.Toolbar>

  <Button
                android:id="@+id/sign_up_button"
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="26dp"
                android:layout_marginBottom="8dp"
                android:text="SUBMIT"
                android:textStyle="bold"
                android:textColor="@android:color/white"
                android:background="@color/colorAccent"/>

0 个答案:

没有答案