2013-08-30 2 views
0

두 개의 TextView가 있습니다. 첫 번째 것이 너무 길면 두 번째 것이 사라집니다. 나는 android:layout_alignParentRight="true"으로 RelativeLayout을 시도했지만 실제로는 그렇지 않습니다.첫 번째 TextView가 너무 길면 두 번째 디 서퍼

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="@dimen/list_margin" 
     android:text="@string/movie_title" 
     android:textColor="#FFFFFF" 
     android:textSize="22sp" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_toRightOf="@+id/textView1" 
     android:layout_marginLeft="@dimen/list_margin" 
     android:text="@string/new_sounds" 
     android:textColor="#8C1717" 
     android:textSize="13sp" 
    android:visibility="1"/> 

</RelativeLayout> 

첫째 텍스트 뷰는 영화 제목과 가끔 보이는 다른 텍스트가있을 것입니다 ListView에 단일 행의 레이아웃이 될 것. 그러나, 내가 말했듯이, 영화 제목이 길 때 textView2은 화면에 보이지 않습니다. 첫 번째 텍스트가 끝나는 곳에서 처리하려면 어떻게해야합니까 (예 : 두 번째 줄에서 끝나면 옆에 textView2이 표시됨)

+0

변경 안드로이드를 공유 할 수 있습니다에 layout_alignParentLeft는 = "true"로 textView1. 이것은 트릭을해야합니다. 작동하는지 기록하십시오. –

+0

아닙니다. 전체적으로'android : layout_weight'로 LinearLayout을 만들었습니다. 내가 원한 것이 아니지만 잘 작동합니다. – Roval

답변

0

android:layout_width="wrap_content"을 사용 했으므로 텍스트보기가 다음과 같이 변경됩니다. 그 안에있는 텍스트로 오래. 이 값을 android:layout_width="match_parent" 또는 특정 너비로 ​​변경하면 지정된 값으로 제한됩니다. layout_width = "wrap_content"(두 textViews)를 match_parent하기 위해, 그리고 안드로이드를 추가 :

+0

이것은 이미 답변에 대한 설명입니다. –

+0

@ divoom12 게시 후 알게되었습니다. 나는 그 페이지를 새롭게하지 않았다. – mou

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="@dimen/list_margin" 
    android:layout_weight="1" 
    android:text="@string/movie_title" 
    android:textColor="#FFFFFF" 
    android:textSize="22sp" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="@dimen/list_margin" 
    android:layout_weight="1" 
    android:text="@string/new_sounds" 
    android:textColor="#8C1717" 
    android:textSize="13sp" /> 

</LinearLayout> 
0

방금 ​​각 텍스트 뷰에 android:layout_weight="1"을 설정해야합니다, 그 후에는

관련 문제