7

TextInputLayoutとSpinnerの配置に問題があります.Spinnerの下線をTextInputLayout内のEditTextの下線に揃えてください。TextInputLayoutとSpinnerを使用したアラインメントの問題

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="bottom"> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <EditText 
      android:id="@+id/txt_discipline_code" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/lbl_input_discipline_code"/> 
    </android.support.design.widget.TextInputLayout> 

    <Spinner 
     android:id="@+id/spnnr_color_discipline_register" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/Base.Widget.AppCompat.Spinner.Underlined"> 

    </Spinner> 
</LinearLayout> 

しかし、スピナーは little bit belowです:これは私がやっているものです。誰でも私を助けることができますか?前もって感謝します。

編集:ここでは

は私が欲しいものです:The Y underline of the EditText equal to the Y underline of the Spinner

私はこのアライメントは1.5dpするスピナーlayout_marginBottomを設定達する:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="bottom"> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <EditText 
      android:id="@+id/txt_discipline_code" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Code"/> 
    </android.support.design.widget.TextInputLayout> 

    <Spinner 
     android:id="@+id/spnnr_color_discipline_register" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/Base.Widget.AppCompat.Spinner.Underlined" 
     android:layout_marginBottom="1.5dp"> 

    </Spinner> 
</LinearLayout> 

しかし、私は、これはないだろう怖いです異なるサイズの他のデバイスでも正しく動作します。それは唯一の解決策ですか?あなたはこの結果をachiveたい言及したものから

+0

私の編集した答えを確認してください –

答えて

2

enter image description here

使用このコード:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:gravity="bottom" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:baselineAligned="false"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:srcCompat="@drawable/ic_launcher" 
      android:id="@+id/imageView" 
      android:padding="10dp" 
      android:layout_weight="5" /> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 
      <EditText 
       android:id="@+id/name_text" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.5" 
       android:hint="Name"/> 
     </android.support.design.widget.TextInputLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:srcCompat="@drawable/ic_launcher" 
      android:id="@+id/imageView1" 
      android:padding="10dp" 

      android:layout_weight="1.1" /> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="-12dp" 
      android:layout_marginStart="-12dp" 
      android:layout_weight="0.6"> 
      <EditText 
       android:id="@+id/code_text" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 

       android:hint="Code"/> 
     </android.support.design.widget.TextInputLayout> 

     <Spinner 
      android:id="@+id/spnnr_color_discipline_register" 
      android:layout_width="match_parent" 
      android:layout_weight="1" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:srcCompat="@drawable/ic_launcher" 
      android:id="@+id/imageView2" 
      android:padding="10dp" 
      android:layout_weight="5" /> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 
      <EditText 
       android:id="@+id/foo_text" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.5" 
       android:hint="Foo"/> 
     </android.support.design.widget.TextInputLayout> 
    </LinearLayout> 


</LinearLayout> 

はそれが役に立てば幸い!

+0

答えをありがとうございますが、私はこれを達成したいと思います - > [リンク](http://imgur.com/a/ivuWg)、電話アイコン付きの行。 – caiofilipemr

+0

あなたはなぜそれを最初から言わなかったのですか? –

+0

申し訳ありませんが私は明確ではない(英語は私の母国語ではありません)、私は電話のアイコンについてあなたに話しました。私はアイコンを望んでいない、ちょうどEditTextとその行のスピナーが持っています。私は質問を編集してより明確にした。解決策も見つけましたが、すべてのディスポジティブに有効かどうかはわかりません。ありがとうございました! – caiofilipemr

関連する問題