2014-10-02 5 views
1

왼쪽 창은 Listview이고 오른쪽 창은 세부 사항보기 인 SlidingPaneLayout이 있습니다. XML은 다음과 같습니다.SlidingPaneLayout의 Listview 부분에 너비를 100 %로 설정하는 방법

문제는 - 어떻게 전체 화면을 커버하기 위해리스트 뷰의 너비를 만들 수 있습니까? 아래에서 볼 수 있듯이 (빨간색 화살표) 현재 너비는 화면 오른쪽으로 이동하지 않습니다.

enter image description here

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.SlidingPaneLayout  xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/sliding_pane_layout" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" > 

<!-- 
    The first child view becomes the left pane. When the combined 
    desired width (expressed using android:layout_width) would 
    not fit on-screen at once, the right pane is permitted to 
    overlap the left. 
--> 

<LinearLayout 
    android:id="@+id/ll_left_pane" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_marginRight="0dp" > 

    <ListView 
     android:id="@+id/left_pane" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 


     android:layout_marginRight="0dp" /> 
</LinearLayout> 

<!-- 
    The second child becomes the right (content) pane. In this 
    example, android:layout_weight is used to express that this 
    pane should grow to consume leftover available space when the 
    window is wide enough. This allows the content pane to 
    responsively grow in width on larger screens while still 
    requiring at least the minimum width expressed by 
    android:layout_width. 
--> 


<!-- Framelayout to display Fragments --> 

<FrameLayout 
    android:id="@+id/frame_container_slidingpanedetailview" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_marginLeft="10dp" /> 

</android.support.v4.widget.SlidingPaneLayout> 

답변

1

이 경우의리스트 뷰를 따라서 일정 값을리스트 뷰의 폭 파라미터를 변경 500dp 또는 1000dp 같은 폭 특성에 매우 큰 값을 넣어 결합된다. XML에서,리스트 뷰에 대한 속성 아래

<ListView 
     android:id="@+id/left_pane" 
     android:layout_width="500dp" 
     android:layout_height="match_parent" 


     android:layout_marginRight="0dp" /> 
+0

좋아,하지만 난 화면 폭을 감지하는 자바에 특별한 코드를 추가하고 설정해야 궁금 그것 이상이거나 1000dp와 같은 큰 가치는 그것을 돌볼 것인가 아닌가를 결정할 것입니다. 감사합니다. 대답으로 표시됩니다. – user1406716

+0

화면 너비를 프로 그램 할 수 있습니다. 하지만이 설정은 화면이 반영되기 전에 슬라이딩 패널에 주어져야하므로 화면에 반영되는 것은 의심 스럽습니다. 그래서 상대 너비 값이 여기에서 작동하지 않습니다. –

0

사용 : 응용 프로그램 : layout_widthPercent = "100 %"일