2014-04-25 4 views
0

나는 목록보기 항목에 대한 레이아웃이 있고 그것은 잘못 표시됩니다 (책 descr은 마지막 업데이트 날짜가 넘었습니다). 고칠 수있게 도와 주시겠습니까?올바른 RelativeLayout 사용하십시오하시기 바랍니다

I 전체 텍스트가 사라 bookDescr 항목에

android:layout_above="@+id/lastUpdatedDt" 

을 설정하면 ...

편집 : 나는

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:descendantFocusability="blocksDescendants" 
    android:layout_margin="10dp" 
    android:background="@drawable/big_card_details" 
    android:clickable="true" 
    android:focusable="false"> 

<CheckBox 
    android:id="@+id/icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    style="?android:attr/starStyle" 
    android:layout_marginTop="10dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginLeft="10dp" /> 

    <TextView 
     android:id="@+id/bookTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Book title" 
     android:textSize="16sp" 
     android:layout_alignBaseline="@id/icon" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@id/icon" /> 

    <TextView 
     android:id="@+id/bookSize" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:text="470k" 
     android:layout_alignBaseline="@id/icon" 
     android:textSize="16sp" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="10dp" /> 

<TextView 
    android:id="@+id/lastUpdatedDt" 
    android:layout_width="match_parent" 
    android:layout_height="26dip" 
    android:singleLine="true" 
    android:text="Updated 27.04.2014 17.10" 
    android:textSize="12sp" 

    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignLeft="@id/icon" /> 
<TextView 
     android:id="@+id/bookDescription" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:singleLine="false" 
    android:textSize="10sp" 
    android:text="here should be long description" 
    android:layout_alignEnd="@id/bookSize" 
    android:layout_below="@+id/bookTitle" 
    android:layout_marginTop="20dp" 
    android:layout_alignLeft="@+id/icon" /> 



    <!-- this is the button that will trigger sliding of the expandable view --> 

    <ImageButton 
     android:id="@+id/expand_details_button" 
     android:src="@drawable/slide_button_details" 
     android:layout_alignTop="@id/lastUpdatedDt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@null" 
     android:layout_alignBaseline="@id/lastUpdatedDt" 
     android:layout_alignParentBottom="true" 
     android:layout_alignRight="@id/bookSize" 
     android:layout_alignEnd="@id/bookSize" /> 

    </RelativeLayout> 

<!-- this is the expandable view that is initially hidden and will slide out when the more button is pressed --> 
<LinearLayout 
    android:id="@+id/details_expandable" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:baselineAligned="false" 
    android:orientation="horizontal" 
    > 
    <!-- put whatever you want in the expandable view --> 
    <Button 
     android:layout_width="match_parent" 
     android:layout_weight="0.3" 
     android:drawableTop="@drawable/ic_action_read" 
     android:text="@string/ReadBook" 
     style="@style/SlideButtonTheme" /> 
    <Button 
     android:layout_width="match_parent" 
     android:layout_weight="0.3" 
     android:drawableTop="@drawable/ic_action_open_browser" 
     style="@style/SlideButtonTheme" 
     android:text="@string/OpenInBrowser" /> 

</LinearLayout> 
</LinearLayout> 
+3

문제점 지금까지 확인한 문제 : ** 1 ** - 레이아웃이 너무 많습니다. ** 2 ** - xmlns가 반복됩니다 (잘못되었습니다!). ** 3 ** - ID에 REFERRING 할 때'@ id' 대신'@ + id'를 사용합니다 ('@ + id'는 새로운 ID를 생성 할 때만 사용해야합니다). ** 4 ** -'fill_parent'는 API 8 이후에 사용되지 않습니다. API 8 이후에는'match_parent'를 사용해야합니다 –

+0

1. 레이아웃이 3 개입니다 (사용자 정의보기에 최소 필요 https://github.com/tjerkw/ Android-SlideExpandableListView 2. Thx 3. Did not는 thx를 알았습니다. 4. Min sdk는 8이므로 match_parent로 변경합니다. –

+0

1 - 레이아웃이 4 개이므로 많이 semplify 할 수 있습니다 (1 또는 2로 줄일 수도 있음). 또는 최악의 경우 3) - 깊이 질문을 공부하지 않을 것입니다. 레이아웃을 적게 사용하면 (컨트롤이 적을수록) 더 나은 실적을 얻을 수 있으므로 더 나은 결과를 얻을 수 있습니다 사용자 경험. –

답변

0

이 당신의 인식을 희망 의견에 따라 샘플을 업데이트했습니다 RelativeLayout의 하위 뷰는 below/above any of the sibling views 또는 aligned from the parent이어야합니다.

여기서 문제 lastUpdatedDt 상위 RelativeLayout 높이 아이 뷰에 기초하여 결정한다 wrap_content 높이로 설정되어 있으므로 lastUpdatedDt 하단에 배치되도록, aligned to parent bottom 인 중첩 상위 높이에 의존한다는 것이다 형제보기입니다.

FIX 다음 lastUpdatedDt 항상 부모의 바닥을 배치하고 bookDescriptionTextView 형제 이하로되도록 그냥의 lastUpdatedDtTextView에 대한 android:layout_below="@+id/bookDescription"을 설정합니다.

+0

설명 및 수정! –