2014-05-11 2 views
0

enter image description here정렬은

가 어떻게이 500 (TextView) 일치 위 checkbox의 왼쪽 가장자리 할 수 ​​RelativeLayout의 수직 뷰의 가장자리를 왼쪽?

나는 RelativeLayout

<ImageView 
    android:id="@+id/group_indicator" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:src="@drawable/expander_open_holo_dark" /> 

<TextView 
    android:id="@+id/lblListHeader" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" 
    android:textSize="17sp" /> 

<CheckBox 
    android:id="@+id/GroupCheckBox" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_alignParentRight="true" 
    android:focusable="false" 
    android:paddingRight="10dp" 
    android:scaleX="2" 
    android:scaleY="2" /> 

<SeekBar 
    android:id="@+id/GroupSeekbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@id/lblListHeader" 
    android:layout_alignParentLeft="true" 
    android:layout_toLeftOf="@+id/GroupSeekCount" 
    android:layout_below="@id/lblListHeader" 
    android:focusable="false" 
    android:max="1000" 
    android:paddingBottom="0dp" 
    android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" 
    android:paddingTop="20dp" > 
</SeekBar> 

<TextView 
    android:id="@+id/GroupSeekCount" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:paddingRight="10dp" 
    android:paddingTop="20dp" 
    android:text="500" 
    android:layout_below="@id/GroupCheckBox" 

    /> 

답변

1
// try this way,hope this will help you... 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="5dp"> 

    <ImageView 
     android:id="@+id/group_indicator" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:src="@drawable/expander_open_holo_dark" /> 

    <CheckBox 
     android:id="@+id/GroupCheckBox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentRight="true" 
     android:scaleX="2" 
     android:scaleY="2" /> 

    <TextView 
     android:id="@+id/lblListHeader" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@id/group_indicator" 
     android:layout_toLeftOf="@id/GroupCheckBox" 
     android:textSize="17sp" /> 

    <SeekBar 
     android:id="@+id/GroupSeekbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:max="1000" 
     android:paddingBottom="0dp" 
     android:layout_below="@id/lblListHeader" 
     android:layout_toLeftOf="@id/GroupCheckBox" 
     android:layout_alignBaseline="@id/lblListHeader" 
     android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" 
     android:paddingTop="20dp" /> 

    <TextView 
     android:id="@+id/GroupSeekCount" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@id/GroupCheckBox" 
     android:layout_toRightOf="@id/GroupSeekbar" 
     android:paddingTop="10dp" 
     android:text="500"/> 

</RelativeLayout> 
+0

감사. 이것은 Evan이 제안한 것과 동일하지만. RelativeLayout 만 사용하려고했습니다. –

+0

이제 RelateLayout을 사용하여 요구 사항을 수행 한 적이 있으므로이 체크 아웃하십시오. –

+0

위대한 작품입니다 .. 제가 누락 된 핵심 부분을 말씀해 주시겠습니까? 레이아웃이 많이 변경된 것 같습니다. –

1

내가 많이 다르게 이것에 대해 갈 것이라고 사용하고 있습니다.

확장자 및 목록 머리글을 수평 선형 레이아웃으로 그룹화 한 다음 확인란 및 500 텍스트를 세로 선형 레이아웃으로 그룹화하십시오. 마지막으로,이 두 선형 레이아웃은 수평 선형 레이아웃 내에 중첩되어야합니다.

+0

나는 그것을 할 수 있지만 성능상의 이유로 –

+0

좋아, 다음, paddingRight 다음 일치하는 폭 떨어져있을 것이다 체크 박스 500 텍스트 고정 폭을 시도하고십시오에 대한 단일 뷰 그룹에 보관하고 싶어 그들은 잘 정렬해야합니다. –

+0

방법이있다, 나는 그것을 하드 코딩하지 않고 체크 박스와 동일한 500 textview의 너비를 만들 수 있습니다. 나는 그것을 다른 디스플레이에서 적절하게 스케일링하지 않을 것을 하드 코딩하는 것에 대해 우려하고있다. –

1

먼저 CheckBox를 정의한 다음 TextView 만 정의하십시오.
이 이렇게하려면 :
그리고는 컨트롤이 계산 줄이기 위해 (이 남은 공간을 차지하도록) match_parent하는

또한, 이미지 뷰가 텍스트 뷰 (복합 당김)의 일부가 될 수있는 텍스트 뷰의 layout_width를 설정합니다 : 항상 (

Drawable drw = getContext().getResources().getDrawable(R.drawable.expander_open_holo_dark); 
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(drw, null, null, null); 

더 나은 : 그럼 당신은 코드에 의해 그룹의 표시를 수정할 수 있습니다

android:drawableLeft="@drawable/expander_open_holo_dark" 
android:drawablePadding="8dp" 

다음 텍스트 뷰 정의에 이러한 속성을 설정 디자인을 최적화하기위한 목적을 염두에두면) CheckedTextView 컨트롤을 사용하여 이미지, 텍스트 및 체크 표시를 단일 컨트롤에 포함 할 수 있습니다 (TextView를 확장하기 때문에 복합 드로어 블뿐만 아니라 TextView 않습니다).

물론 오른쪽으로 눈금을 이동할 수 있습니다.

+0

500 TextView가 마지막으로 정의됩니다. 500은 다음 행에 있습니다. 500으로 설정하면 극단적으로 왼쪽으로 이동합니다. –

+0

그래서! "GroupSeekCount"입니다. 글쎄, 나는 그 질문을 제대로 이해하지 못했습니다. 따라서 간단히 부모의 하단과 CheckBox Left에 정렬 할 수 있습니다 (선택 사항). 끝난. –