2017-05-07 4 views
0

내 앱의 경우 부모의 오른쪽 끝에 정렬 된 스피너가 있어야합니다.Android - Spinner가 부모 끝까지 올바르게 정렬되지 않았습니다.

<Spinner 
      android:id="@+id/createsub_cycle_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView3" 
      android:layout_alignParentEnd="true" 
      android:layout_below="@+id/imageView2" 
      android:layout_marginEnd="10dp" 
      android:textColorHint="@android:color/white" 
      android:textSize="18sp" /> 

볼, alignParentEndtrue으로 설정됩니다

이 내 스피너 XML이다. 나는 응용 프로그램을 실행할 때

는 아직도 resut는 다음과 같습니다 :

gap

"주간"의 오른쪽에 차이가 없을 것이다. 파란색 레이아웃의 맨 끝에 맞추어야합니다.

어떻게 수정합니까?

EDIT :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<android.support.v7.widget.CardView 
    android:id="@+id/createsub_card" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="10dp"> 


    <ImageView 
     android:id="@+id/createsub_image" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:scaleType="fitCenter" 
     android:layout_gravity="center_horizontal" 
     android:layout_margin="20dp" /> 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="80dp"> 

     <TextView 
      android:id="@+id/createsub_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <EditText 
      android:id="@+id/createsub_user_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_marginEnd="10dp" 
      android:maxLines="1" 
      android:onClick="onTitleClicked" 
      android:textAlignment="center" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:layout_below="@id/createsub_title" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/createsub_price" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/createsub_title" 
      android:layout_margin="10dp" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <Spinner 
      android:id="@+id/createsub_currency_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView2" 
      android:dropDownWidth="40dp" 
      android:layout_alignParentEnd="true" 
      android:layout_below="@id/createsub_user_title" 
      android:layout_marginEnd="10dp" /> 

     <EditText 
      android:id="@+id/createsub_user_price" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView2" 
      android:layout_alignTop="@id/createsub_currency_spinner" 
      android:layout_toStartOf="@id/createsub_currency_spinner" 
      android:inputType="numberDecimal" 
      android:maxLines="1" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" 
      android:hint="0.00" 
      android:textColorHint="@android:color/white"/> 


     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:layout_below="@id/createsub_price" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/createsub_cycle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/createsub_price" 
      android:layout_margin="10dp" 
      android:text="@string/cycle" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <Spinner 
      android:id="@+id/createsub_cycle_spinner" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView3" 
      android:layout_alignParentEnd="true" 
      android:layout_below="@+id/imageView2" 
      android:layout_marginEnd="10dp" 
      android:textColorHint="@android:color/white" 
      android:textSize="18sp" /> 

     <ImageView 
      android:id="@+id/imageView3" 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:layout_below="@id/createsub_cycle" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/createsub_firstbill" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/createsub_cycle" 
      android:layout_margin="10dp" 
      android:text="@string/first_bill" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 


     <!--TODO: when clicked has to show datepickerdialog--> 
     <EditText 
      android:id="@+id/createsub_user_firstbill" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView4" 
      android:layout_alignEnd="@+id/imageView4" 
      android:layout_below="@+id/imageView3" 
      android:inputType="date" 
      android:maxLines="1" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <ImageView 
      android:id="@+id/imageView4" 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:layout_below="@id/createsub_firstbill" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/createsub_duration" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/createsub_firstbill" 
      android:layout_margin="10dp" 
      android:text="@string/duration" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <Spinner 
      android:id="@+id/createsub_duration_selector" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/imageView5" 
      android:layout_alignParentEnd="true" 
      android:layout_below="@+id/imageView4" 
      android:layout_marginEnd="10dp" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <ImageView 
      android:id="@+id/imageView5" 
      android:layout_width="match_parent" 
      android:layout_height="1px" 
      android:layout_below="@id/createsub_duration" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="10dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/createsub_remindme" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/createsub_duration" 
      android:layout_margin="10dp" 
      android:text="@string/remind_me" 
      android:textColor="@android:color/white" 
      android:textSize="18sp" /> 

     <Spinner 
      android:id="@+id/createsub_reminder_selector" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignEnd="@+id/createsub_user_firstbill" 
      android:layout_below="@+id/imageView5" 
      android:textColorHint="@android:color/white" 
      android:textSize="18sp" /> 


    </RelativeLayout> 
</android.support.v7.widget.CardView> 

답변

1

여기 당신이 시도 할 수있는 두 가지이다 :

  1. 난 당신이 android:dropDownWidth40dp에 하드 코딩하는 것을 알 수 있습니다. "weekly"텍스트의 길이가 반드시 40dp 일 수는 없습니다. 해당 특성을 제거하십시오. 회 전자의 배경을 설정

  2. 봅니다 캐럿의 답변

    <Spinner 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@null"/> 
    
+1

도움을 주셔서 감사합니다. 부분적으로 그 것이 었습니다. 다른 것은 스피너가 배열을 기반으로하고 그 배열에 "weekly"보다 긴 문자열이 있기 때문에 그는 그 공간을 유지하고있었습니다. 필자는 텍스트를 끝에 정렬하여 간격을 제거하는'spinner_item.xml'에'android : textAlignment = "viewEnd"'를 추가하여이를 해결했습니다. – Daniele

0

가 cardview 태그 삭제 본

이것은

android:layout_marginEnd="10dp"

제거 : 여기

전체 배치도이다

android:layout_margin="10dp";

+0

덕분에 공간을 제거하는 null로. 그것을 제거한 후, 그것은 10dp를 낙하로 이동하지만 레이아웃의 맨 마지막으로 이동하지 않습니다. – Daniele

+0

전체 레이아웃 게시, –

+0

업데이트 된 질문을 살펴보십시오. 전체 레이아웃을 추가했습니다. 그것은 꽤 길다 – Daniele