문제

서로가 달리는 관계에서 같은 높이에있는 두 개의 텍스트 뷰에 문제가 있습니다.

다음 레이아웃을 사용합니다.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent">

<ImageView 
       android:id="@+id/logo" 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
       android:adjustViewBounds="true"
       android:scaleType="centerInside"
       android:src="@drawable/icon" />

<TextView 
       android:id="@+id/name"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content" 
       android:text="NameNameNameNameNameNameName"
       android:layout_alignParentTop="true"
       android:layout_toRightOf="@id/logo"
       android:gravity="clip_horizontal" 
       android:lines="1" />

<TextView 
      android:id="@+id/information"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Distance"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true" />

<TextView
      android:id="@+id/nrcoupons"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Number"
      android:layout_alignRight="@id/information"
      android:layout_alignBottom="@id/logo" />

<TextView
      android:id="@+id/subcategory"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:text="Subcategory"
      android:layout_alignLeft="@id/name"
      android:layout_alignBottom="@id/logo" />

</RelativeLayout>

이것은 나 에게이 견해를 준다 :

대체 텍스트 http://janusz.de/~janusz/view.png

두 개의 텍스트 뷰 이름과 정보가 동일한 화면 공간에 다른 하나의 상단에 표시되는 것을 제외하고는 필요한 모든 것이 필요합니다.

이것을 피하려면 어떻게해야합니까?

도움이 되었습니까?

해결책

당신을 위해 @+id/name TextView, 추가하다 android:layout_toLeftOf="..." 무엇이든 TextView 오른쪽에 있습니다. 스크린 샷과 XML은 정렬되지 않는 것 같습니다 (스크린 샷은 덮어 쓰기 텍스트 뷰에서 "거리"가있는 것으로 보이지만 XML은 그렇지 않습니다).

Android 1.5를 타겟팅하는 경우 위젯이 참조되기 전에 정의되도록 XML에서 위젯을 주문해야합니다. android:layout_toLeftOf 또는 android:layout_toRightOf. Android 1.6을 타겟팅하고 최신만으로는 어떤 순서로든 가질 수 있지만, 별개의 ID의 첫 번째 발생에는 + 서명, 첫 번째 사건이 android:layout_toLeftOf 대신 속성 android:id 기인하다.

다른 팁

NamenameName TextView는 width = fill_parent로 설정되어 있으므로 오른쪽에 아무것도 넣을 수 없습니다.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top