0

可能な限り短くしてください。TextInputLayoutとAutoCompleteTextViewの背景がプレビューでうまく見えますが、デバイスでは常に白です。

これはTextInputLayout

<style name="TextLabel" parent="Widget.AppCompat.AutoCompleteTextView"> 
    <!-- Hint color and label color in FALSE state --> 
    <item name="android:textColorHint">@color/pure_white</item> 
    <!-- Label color in TRUE state and bar color FALSE and TRUE State --> 
    <item name="colorAccent">@color/pure_white</item> 
    <item name="colorControlNormal">@color/pure_white</item> 
    <item name="colorControlActivated">@color/pure_white</item> 
    <!-- When everything else failed I tried this but with no effect --> 
    <item name="android:background">@android:color/transparent</item> 
</style> 

のための私のスタイルであり、これはレイアウト

<android.support.design.widget.TextInputLayout 
     android:theme="@style/TextLabel" 
     android:layout_margin="@dimen/activity_margin_basic_double" 
     android:layout_centerInParent="true" 
     android:id="@+id/team_name_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <AutoCompleteTextView 
      android:id="@+id/new_team_name" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/prompt_team_create" 
      android:maxLines="1" /> 

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

で実装されており、これは私が(物理的およびエミュレートさの両方)デバイス上に得るものです: enter image description here

これは私が実際に欲しいものです.Android Studioのプレビューでは正しく表示されていますが、これは単にコンパイルされません方法:

enter image description here

これはしてください並べ替えを取得する方法任意のアイデア?私は数日を無駄にしてしまいましたが、問題を理解することはできません。

事前に感謝します! Sloba

答えて

1

問題はあなたのスタイルにあります。表示されている結果でWidget.AppCompat.AutoCompleteTextViewTextInputLayoutに適用しています。この親スタイルをAppThemeに変更するか、android:theme="@style/TextLabel"AutoCompleteTextViewに移動して親を変更することはできません。私は下の最初の方法を示します。

この小さなビデオは、あなたが望むものを得るために私が行った変更を示しています。どのように動作しているかをよりよく示すためにいくつかの点を追加しました。それはあなたの必要とするものの100%ではないかもしれませんが、それはあなたをスレッシュホールド以上にする必要があります。ここで

Demo video

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:background="#FFcc9c00" 
    android:orientation="vertical"> 

    <android.support.design.widget.TextInputLayout 
     android:id="@+id/team_name_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="8dp" 
     android:theme="@style/TextLabel"> 

     <AutoCompleteTextView 
      android:id="@+id/new_team_name" 
      android:layout_width="match_parent" 
      android:hint="Choose a Team Name" 
      android:layout_height="wrap_content" 
      android:maxLines="1" /> 
    </android.support.design.widget.TextInputLayout> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/team_name_container" 
     android:layout_margin="8dp" 
     android:hint="EditText hint" /> 
</RelativeLayout> 

とのstyles.xml:

<resources> 
    <!-- 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> 
    </style> 
    <style name="TextLabel" parent="AppTheme"> 
     <!-- Hint color and label color in FALSE state --> 
     <item name="android:textColorHint">@android:color/white</item> 
     <!-- Label color in TRUE state and bar color FALSE and TRUE State --> 
     <item name="colorAccent">@android:color/white</item> 
     <item name="colorControlNormal">@android:color/white</item> 
     <item name="colorControlActivated">@android:color/white</item> 
    </style> 
</resources> 
+0

OMG、そんなにありがとう問題は、私が実際に適用されたことでした'style'属性を持つTextLabelスタイルですが、' android:theme'属性でそれを適用することになっていました。 –

関連する問題