Высота не работает с элементами Android - PullRequest
0 голосов
/ 26 февраля 2019

Высота кнопок и панели инструментов не работает с моим приложением для Android, как в представлении Android Studio, так и при запуске приложения на устройстве.

Все элементы не имеют высоты и имеют плоский вид.

Это мое определение стиля

<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"/>
...