2012-10-29 4 views
0

XML의 세부 정보가 좋지 않아 다음 문제에 대한 해결책을 찾을 수 없습니다.행 xml의 요소 정렬

나는 ListView를 가지고있다. 텍스트가 짧은

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="center_vertical" > 

     <TextView 
      android:id="@+id/date" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:textColor="#ff888888" 
      android:textSize="10dp" 
      android:paddingRight="5dp" 
      android:paddingTop="5dp" 
      android:paddingBottom="5dp" 
      android:paddingLeft="5dp" 
      android:text="02 OCT" 
      android:textStyle="bold" 
     /> 


     <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 

      android:textColor="#ff000000" 
      android:textSize="14dp" 
      android:singleLine="true" 
      android:ellipsize="end" 
      android:paddingLeft="5dp" 
      android:paddingRight="5dp" 
      android:paddingTop="5dp" 
      android:paddingBottom="5dp" 
      android:text="GIRLFRIEND COFFE AT STARBUCKS COFFE" 
      android:maxWidth="250dip" 
     /> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 

      android:background="@drawable/icon_clip" 
      android:layout_marginTop="5dp" 
      android:layout_marginBottom="5dp" 
      android:id="@+id/img_posted_check" 
     /> 
     <TextView 
      android:id="@+id/relleno" 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:textColor="#ff000000" 
      android:textSize="14dp" 
      android:singleLine="true" 
      android:ellipsize="end" 
      android:paddingLeft="5dp" 
      android:paddingRight="5dp" 
      android:paddingTop="5dp" 
      android:paddingBottom="5dp" 
      android:text="" 
     /> 

     <TextView 
      android:id="@+id/amount" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#ff000000" 
      android:textSize="14dp" 
      android:paddingLeft="5dp" 
      android:paddingTop="5dp" 
      android:paddingBottom="5dp" 
      android:paddingRight="5dp" 
      android:text="$13.34" 
     /> 
</LinearLayout> 

, 난 괜찮 볼 수 있습니다 : enter image description here

을하지만 텍스트 설명이 너무 긴 경우, 그것의 한계까지 모든 공간을 차지 하나의 행은 다음 XML 코드와 같이 정의된다 창을 열고 가격과 클립 마커를 꺼내는 "..."로 잘라냅니다.enter image description here 제목 ID가있는 텍스트보기에 가중치 속성을 추가하는 클립을 사용하지 않는 경우에만이 작업을 수행 할 수 있습니다 (@ + id/title) 'relleno'라는 레이아웃이없는 경우. 나는이 추측

+0

이 정확히 달성하려고하는 무엇 사용 ? 'TextView'는'android : singleLine = "true"'로 설정됩니다.이 행을 지우면 텍스트가 다음 행으로 넘어갑니다. – jnthnjns

+0

날짜, 설명, 클립 이미지 (옵션), 가격 (오른쪽 정렬) 등의 요소를 원합니다. 모두 한 줄에 있습니다. – moskis

답변

1

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

<TextView 
    android:id="@+id/date" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="5dp" 
    android:text="02 OCT" 
    android:textColor="#ff888888" 
    android:textSize="10dp" 
    android:textStyle="bold" /> 

<TextView 
    android:id="@+id/title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toLeftOf="@+id/img_posted_check" 
    android:layout_toRightOf="@+id/date" 
    android:ellipsize="end" 
    android:maxWidth="250dip" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="5dp" 
    android:singleLine="true" 
    android:text="GIRLFRIEND COFFE AT STARBUCKS COFFE" 
    android:textColor="#ff000000" 
    android:textSize="14dp" /> 

<ImageView 
    android:id="@+id/img_posted_check" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="5dp" 
    android:layout_marginTop="5dp" 
    android:layout_toLeftOf="@+id/relleno" 
    android:background="@drawable/ic_launcher" /> 

<TextView 
    android:id="@+id/relleno" 
    android:layout_width="0dip" 
    android:layout_height="wrap_content" 
    android:layout_toLeftOf="@+id/amount" 
    android:ellipsize="end" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="5dp" 
    android:singleLine="true" 
    android:text="" 
    android:textColor="#ff000000" 
    android:textSize="14dp" /> 

<TextView 
    android:id="@+id/amount" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    android:paddingTop="5dp" 
    android:text="$13.34" 
    android:textColor="#ff000000" 
    android:textSize="14dp" /> 

</RelativeLayout> 
+0

정확하지 않습니다. 아이콘에는 설명 텍스트가 있어야합니다. – moskis

0

는 그런 다음 텍스트 뷰와 이미지 뷰를 대체 할 수 원하는 것입니다 ..이

<TextView 
     android:id="@+id/img_posted_check" 
     android:layout_width="300dp" 
     android:gravity="center" 
     android:layout_height="wrap_content" 
     android:drawableLeft="@drawable/ic_launcher" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="5dp" 

     android:text="hiiii" />