2014-07-13 4 views
1

보기에 파란색 막대가 표시되도록하려고하지만 목록에 표시 할 수 없습니다. 참고 목록보기보기가 RelativeLayout에 표시되지 않음

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white"> 
    <LinearLayout 
     android:id="@+id/list_img_ll" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/imgList1" 
      android:layout_width="wrap_content" 
      android:layout_height="80dp" 
      /> 

    </LinearLayout> 

    <View android:id="@+id/state_open" 
     android:layout_alignParentRight="true" 
     android:layout_width="20dp" 
     android:layout_height="match_parent" 
     android:background="@color/CVBlue" /> 
</RelativeLayout> 

의 getView() 메소드

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 

    View row = convertView; 
    RecordHolder holder = null; 

    if (row == null) { 

     LayoutInflater inflater = ((Activity) context).getLayoutInflater(); 
     row = inflater.inflate(layoutResourceId, parent, false); 

     holder = new RecordHolder(); 
     holder.imageItem = (ImageView) row.findViewById(R.id.imgList1); 
     holder.stateView = row.findViewById(R.id.state_open); 

     row.setTag(holder); 

    } else { 

     holder = (RecordHolder) row.getTag(); 

    } 

    Item item = data.get(position); 
    holder.imageItem.setImageBitmap(item.getImage()); 




    return row; 

} 

이 결과를 나중에 생성하면서 화상을 설정한다. 생성하려고 시도하지만 작동하지 않는 것 같습니다 오른쪽 상단 모서리에 유의하십시오. 또한 내가 relativelayout의 높이를 설정할 때 작동하고 매우 혼란 스럽습니다. 작업 하나도 http://i.stack.imgur.com/xAlpg.png

이의 이미지는 RelativeLayout의 크기 http://i.stack.imgur.com/SCRTu.png

+0

더 나은 질문을 설명해주십시오, 당신의 프로그램에 문제가 있는지 몰라, 내가 오른쪽 상단에 생성 된 이미지에 어떤 문제가 있는지 이해가 안 돼요. – NebulaeGuy

+0

나쁜 설명에 대해 유감스럽게 생각합니다. 이미 원하는 이미지를 게시했습니다. @NebulaeGuy – IndyZa

답변

2

문제가있는 LinearLayout 인에게 config (설정) 할 필요없이 내가 원하는 무언가이다.

android:layout_toLeftOf="@+id/state_open" 

문제는 당신이 전체 화면의 폭을 차지 match_parent 할 수있는 LinearLayout의 폭을 설정한다는 것입니다 : 다음과 같은 속성을 추가합니다. 보기에 남은 공간을 남기지 않습니다. 왼쪽으로 설정하면보기에 사용 가능한 공간을 모두 차지하지 않습니다.

알 수 있습니다. 아주 이상한. state_open 뷰 추가에 :

android:layout_alignTop="@+id/list_img_ll" 
android:layout_alignBottom="@+id/list_img_ll" 

문제는 state_open보기가보기에 적절한 높이를 얻고있다 ... 비록 색상 값을 제공하기 위해 얼마나 높이를 알 수 없다는 것입니다. LinearLayout에 맞추면됩니다. 또 다른 해결책은 view에 match_parent 대신 실제 dp 크기를 지정하는 것입니다. 즉, 80dp. 가장 이상한 일.

+0

감사하지만보기가 여전히 제대로 표시되지 않습니다. http://i.stack.imgur.com/bI6g0.jpg – IndyZa

+0

흠. 그 흥미 롭군요. 그 경계선은 그 스크린 샷에서 더 잘 어울립니다. getView() 메소드를 게시 할 수 있습니까? –

+0

좋아요. getView()에 대한 내 게시물을 이미 편집했습니다. – IndyZa

-1

이 시도 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white"> 
    <View android:id="@+id/state_open" 
     android:layout_alignParentRight="true" 
     android:layout_width="20dp" 
     android:layout_height="match_parent" 
     android:background="@color/CVBlue" /> 

    <LinearLayout 
     android:id="@+id/list_img_ll" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="horizontal" 
     android:layout_toLeftOf="@id/state_open"> 

     <ImageView 
      android:id="@+id/imgList1" 
      android:layout_width="wrap_content" 
      android:layout_height="80dp"/> 

    </LinearLayout> 
</RelativeLayout> 
+0

자세한 설명없이 답변을 피하십시오. 정확히 무엇이 바뀌 었습니까? 왜 변한거야? – eftokay83

관련 문제