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> 

을하지만이하지 않습니다 두려워 여기

내가 원하는 것입니다 다른 크기로 다른 장치에서 제대로 작동합니다. 그것은 유일한 해결책입니까? 이 코드

enter image description here

사용 : 당신은 당신이이 결과 실현하려합니다 언급 한 것과

+0

내 대답을 확인하십시오. –

답변

2

<?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