2017-01-13 3 views
0

layout_weight을 사용하여 EditText 필드 오른쪽에 단추를 표시하려고합니다. 내 디자인보기처럼 보일 수있는 컴파일 된 버전을 얻을 수있는 방법이LayoutWeights가 요소를 올바르게 조정하지 않음

enter image description here

있습니까 :

그러나,이 일이 무엇입니까? 여기

내 디자인보기

enter image description here

입니다 그리고 여기 내 레이아웃 코드 :

<ScrollView 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:layout_marginLeft="5dp" 
android:layout_marginRight="5dp" 
android:padding="10dp" 
android:scrollbars="none" 
tools:context="com.mycomapany.myapp.Views.MasterDetails.VehicleFragment"> 


<LinearLayout 
android:id="@+id/llMainView" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 


../// OTHER ELEMENTS 

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

<android.support.design.widget.TextInputLayout 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="2" 
    android:hint="VIN"> 

    <android.support.design.widget.TextInputEditText 
     android:id="@+id/editVIN" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginEnd="5dp" 
     android:background="@color/COLOR_TXI_GREY" 
     android:imeOptions="actionDone" 
     android:inputType="text" 
     android:maxLength="17" 
     android:maxLines="1"/> 
</android.support.design.widget.TextInputLayout> 

<ProgressBar 
    android:id="@+id/pbCheckVIN" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:visibility="gone"/> 

<Button 
    android:id="@+id/btnScanVIN" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:background="@color/COLOR_TXI_BLUE" 
    android:text="SCAN" 
    android:textColor="@color/COLOR_TXI_WHITE" 
    android:textStyle="bold"/> 
</LinearLayout> 


../// OTHER ELEMENTS 

</LinearLayout> 

답변

-1

는,이 시도 더 선형 레이아웃을 배치하고 무게는 그 후 지팡이 어떤 크기 속성 부여 그 텍스트와 버튼 만들기 Linear layout this, 여기 Button과 TextView 뷰에 대한 세부 사항 만 제공합니다.

<LinearLayout 
 
android:layout_width="match_parent" 
 
android:layout_height="match_parent" 
 
android:orientation="vertical">//main Linear Layout 
 
    <LinearLayout 
 
android:laout_weight="1"; 
 
android:layout_width="match_parent" 
 
android:layout_height="0dp" 
 
android:orientation="vertical">//another Linear Layout 
 
    //write code u want 
 
    </LinearLayout> 
 

 
<LinearLayout 
 
android:laout_weight="1"; 
 
android:layout_width="match_parent" 
 
android:layout_height="0dp" 
 
android:orientation="horizontal">//you wanted LinearLayout 
 

 
<android.support.design.widget.TextInputLayout 
 
    android:layout_width="0dp" 
 
    android:layout_height="match_parent" 
 
    android:layout_weight="2" 
 
    android:hint="VIN"> 
 

 
    <android.support.design.widget.TextInputEditText 
 
     android:id="@+id/editVIN" 
 
     android:layout_width="0dp" 
 
     android:layout_height="match_parent" 
 
     android:layout_marginEnd="5dp" 
 
     android:background="@color/COLOR_TXI_GREY" 
 
     android:imeOptions="actionDone" 
 
     android:inputType="text" 
 
     android:maxLength="17" 
 
     android:maxLines="1"/> 
 
</android.support.design.widget.TextInputLayout> 
 
</LinearLayout> 
 
</LinearLayout>

0

답으로 컨텍스트를 제공하기 위해 시도하십시오 TextInputEditText

+0

에서 android:layout_marginEnd="5dp" 속성을 제거하려고 시도합니다. 대답은 문제를 해결할 수 있지만 설명은 많은 미래의 문제를 해결할 수 있습니다. 문제의 원인이라고 생각하는 것을 포함시키고 답변으로 해결할 수있는 이유를 포함 시키십시오. – Newd

+0

@Newd android : layout_marginEnd는 뷰의 경계 밖에서 뷰 끝에 추가 공간을 지정합니다. 이것은 내가 생각하기에 EditText와 Button 사이에 공간이 생겨났습니다. – sats

관련 문제