2016-10-11 4 views
1

私はAndroidアプリ開発の世界ではかなり新しいです。私は現在、いくつかの基本的なことを試しています。現在、さまざまな素材デザインアプリに見られるようなフローティングラベルを実現しようとしています。TextInputLayoutが表示されない

私がしようとしているのは、CardViewを取得し、TextInputLayoutをそのカードに置きます。私はこれを行うときに私が取得することになってるよう

<android.support.v7.widget.CardView 
     android:layout_width="310dp" 
     android:layout_height="250dp" 
     android:layout_below="@+id/textView" 
     android:layout_alignRight="@+id/textView" 
     android:layout_alignEnd="@+id/textView" 
     android:layout_marginTop="13dp" > 

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

       <EditText 
        android:id="@+id/labeltest" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:hint="floating label"/> 
      </android.support.design.widget.TextInputLayout> 
     </RelativeLayout> 
    </android.support.v7.widget.CardView> 

は今、私はCardViewを得るが、TextInputLayoutは表示されません。しかし、私はそれをタップすることができますし、その後、私はテキストを入力することができます。 (下の例を参照)

実際のデバイスではなく、仮想マシンでテストしています。

ありがとうございました。

Example 1

編集:あなたが読んであげるならばcolors.xml

<resources> 
    <color name="colorPrimary">#E43F3F</color> 
    <color name="colorPrimaryDark">#E12929</color> 
    <color name="primary_darker">#CC1D1D</color> 
    <color name="colorAccent">#FFFFFF</color> 

    <color name="black">#000000</color> 
    <color name="jet">#222222</color> 
    <color name="oil">#333333</color> 
    <color name="monsoon">#777777</color> 
    <color name="jumbo">#888888</color> 
    <color name="aluminum">#999999</color> 
    <color name="base">#AAAAAA</color> 
    <color name="iron">#CCCCCC</color> 
    <color name="white">#FFFFFF</color> 
    <color name="Trans_text">#a8ffffff</color> 
</resources> 
+0

アンドロイド:layout_height = "wrap_content" '編集テキスト。あなたの現在のコードでは、親はwrap_contentを持ち、子は0にお互いをキャンセルするmatch_parentを持っているので、適切な子と親のlayout_paramsを持つことを確認してください –

+0

そして、 'TextInputEditText'を' EditText'の代わりに 'TextInputLayout' ://developer.android.com/reference/android/support/design/widget/TextInputEditText.html –

+0

@MohammedAtifちょうど 'android.support.design.widget.TextInputEditText'を試しました。私がそれを使用すると、完全に見えなくなりクローン不可能になります –

答えて

1

、要求ごとのようMaterial Design GuidelinesあなたはcolorAccentがあなたのフィールドの下のラインの色として使用されていることがわかります。 colorAccentが白に設定されているので(colors.xmlファイルを参照)、TextInputLayoutは、parentの背景色と混ざっていて、それも白いものなどです。 colorAccentを赤色などで変更して、問題があるかどうか確認してください。

関連する問題