2

После создания проекта в IntelliJ IDEA форма имеет такой вид:

введите сюда описание изображения

Если в style.xml изменить строку:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

На:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

То контролы на форме появляются, но ActionBar нет!

Если поиграться с кнопкой Theme in Editor, то ActionBar появится, но он не будет иметь цвета которые указаны в style.xml

Также я пробовал менять API Version in Editor - безрезультатно, а ещё пробовал:

  • В build.gradle добавлять/менять/удалять строку:

    implementation 'com.android.support:appcompat-v7:28.0.0'

  • Перейти с ActionBar на ToolBar

  • И ещё много чего пробовал

Что делать? Подскажите, мне, пожалуйста!

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.pony.test_1"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center_horizontal"
              android:orientation="vertical"
              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=".LoginActivity">

    <!-- Login progress -->
    <ProgressBar
            android:id="@+id/login_progress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:visibility="gone"/>

    <ScrollView
            android:id="@+id/login_form"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <LinearLayout
                android:id="@+id/email_login_form"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                <AutoCompleteTextView
                        android:id="@+id/email"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/prompt_email"
                        android:inputType="textEmailAddress"
                        android:maxLines="1"
                        android:singleLine="true"/>

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                <EditText
                        android:id="@+id/password"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/prompt_password"
                        android:imeActionId="6"
                        android:imeActionLabel="@string/action_sign_in_short"
                        android:imeOptions="actionUnspecified"
                        android:inputType="textPassword"
                        android:maxLines="1"
                        android:singleLine="true"/>

            </android.support.design.widget.TextInputLayout>

            <Button
                    android:id="@+id/email_sign_in_button"
                    style="?android:textAppearanceSmall"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:text="@string/action_sign_in"
                    android:textStyle="bold"/>

        </LinearLayout>
    </ScrollView>
</LinearLayout>

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.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>
4
  • Разметку Layout покажите и весь style.xml 19 окт 2018 в 9:43
  • @AndreyMihalev, добавил 19 окт 2018 в 9:47
  • А чем Theme.AppCompat.Light.DarkActionBar не подошла?
    – yno7
    19 окт 2018 в 10:39
  • @yno7, Вы мой пост читали вообще? Тем что так Theme.AppCompat.Light.DarkActionBar не отображаются контролы на форме, а так Base.Theme.AppCompat.Light.DarkActionBar отображаются. Просто пробую по разному, пытаюсь решить проблему. 19 окт 2018 в 10:51

1 ответ 1

0

Я просто в build.gradle изменил строку:

implementation 'com.android.support:appcompat-v7:28.0.0'

На:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

И всё заработало!!!

P.S В style.xml стоит Theme.AppCompat.Light.DarkActionBar

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.