2016-07-23 7 views
1

私はres/values/フォルダにstyle.xmlを以下ましません:スタイルは、エミュレータに表示されますが、私のデバイス上で

<?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" 
    style="@style/AppTheme"          // here I've used It. 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.kaushal28.wakeupplease.MainActivity"> 

    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Start" 
      android:id="@+id/startAlarm" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/stop" 
      android:text="Stop"/> 
    </LinearLayout> 
</RelativeLayout> 

<!-- 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> 
    <item name="android:colorBackground">#000000</item> 
</style> 

と私はstyle="@style/AppTheme"を使用していた私の主な活動は、次のレイアウト

私はAndroid搭載のデバイスを持っています。4.2.2 Jelly Beanとエミュレータには最新のMarsh mellowがあります。私はこの違いが原因だと思う。私はこのプロジェクトのために最低限のSDKバージョン15を持っています。

targetSDKVersionを15に変更しようとしました。しかし、それは私の問題を解決することができませんでした。 Image of Emulator.

表示しているもの:: enter image description here

私が背景に黒い色を期待してい表示されるべきである何

+0

カスタマイズされていないものは何ですか?スクリーンショットを共有することは可能ですか? – W0rmH0le

+0

大丈夫待って....... –

+0

@GuilhermePスクリーンショットを参照 –

答えて

0

android:windowBackground代わり

<!-- 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> 
    <item name="android:windowBackground">@android:color/black</item> 
</style> 

なぜandroid:colorBackgroundを使用してみてください?

あなたの画面では、ウィンドウの背景を設定しようとしていました。だから、その最高の属性はandroid:windowBackgroundです。

AppThemeは、android:windowBackgroundをオーバーライドしていません。android:colorBackgroundをオーバーライドしていました。

android:windowBackgroundをオーバーライドしていないため、Androidは親テーマ(Theme.AppCompat.Light.DarkActionBar)で定義された色を使用します。

<item name="colorBackgroundFloating">@color/background_floating_material_light</item> 

<color name="background_material_light">@color/material_grey_50</color> 
<color name="material_grey_50">#fffafafa</color> 

それはほとんど白い色である:

ので、Androidは使用していました。私は正直なところだろうメーカー

デバイスが..私はエミュレータがそれを使用している間に、なぜあなたのデバイスは、android:colorBackgroundを無視した全くわからないんだけど...

おそらく、APIのバージョンですデバイスはアクティビティに適用されたテーマをコンテキスト全体に表示するので、おそらく通常の動作に過ぎません。あなたのデバイスは、Androidスタジオレイアウトプレビューツールとは少し異なります。どんなたとえば

は、私はあなたが全体のウィンドウの背景を送信したい場合は

android:colorBackgroundは、すべての構成要素、例えばのメインウィンドウの背景だけでなく、影響を与えることができます... android:windowBackgroundを使用することをお勧めしますコンポーネントレイアウトでオーバーライドしないかぎり、ダイアログボックスは表示されません。(この部分はhereから検索されました)

+0

それは働いた。理由は何ですか? –

+0

すべてのパラメータについて、スタイルを使用している間にそのような代替案を見つけましたか? –

+1

@ Kaushal28答えを – W0rmH0le

関連する問題