현재 프로젝트에 대한 작은 업데이트를하고 있으며 목록보기에서 Relative_Layout 및 fill_parent에 문제가 있습니다. 각 행의 두 섹션 사이에 구분선을 삽입하려고합니다. 이는 기본 다이얼러의 호출 로그에있는 구분선과 같습니다. 그들이 안드로이드 소스 코드를 어떻게 체크했는지 확인해 보았지만 솔루션을 복제 할 때 문제가 발생했습니다.안드로이드 RelativeLayout fill_parent 예기치 않은 동작으로 다양한 행 높이를 갖는 ListView
이<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dip"
android:layout_height="fill_parent"
android:maxHeight="64dip"
android:minHeight="?android:attr/listPreferredItemHeight">
<ImageView android:id="@+id/infoimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/info_icon_big"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
<View android:id="@+id/divider"
android:background="@drawable/divider_vertical_dark"
android:layout_marginLeft="11dip"
android:layout_toLeftOf="@+id/infoimage"
android:layout_width="1px"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_marginRight="4dip"/>
<TextView android:id="@+id/TextView01"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView01"
android:layout_toLeftOf="@+id/divider"
android:gravity="left|center_vertical"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"/>
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/bborder"
android:layout_centerVertical="true"/>
</RelativeLayout>
내가 직면하고있어 문제는 각 행은 다양한 높이 (ImageView01)의 축소판을 가지고 있다는 것입니다 : 시작하려면
, 여기 내 행 항목 레이아웃입니다. RelativeLayout의 layout_height 속성을 fill_parent로 설정하면 구분선이 행을 채우도록 세로로 배율을 조정하지 않습니다 (단 1px 점 만 남음). layout_height를 "android : attr/listPreferredItemHeight"로 설정하면 구분선이 행을 채우지 만 축소판은 축소됩니다. 어댑터의 getView() 메소드에서 일부 디버깅을했는데 행의 높이가 적절하면 구분선의 높이가 올바르게 설정되지 않은 것으로 보입니다.
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = inflater.inflate(R.layout.tag_list_item, parent, false);
}
방법의 나머지는 단순히 행에 대한 적절한 텍스트 및 이미지를 설정한다 : 여기서
는의 getView() 메소드의 일부이다.inflater = LayoutInflater.from(context);
나는 필수적인 뭔가를 놓치고 있습니까 :
또한, 내가 가진 어댑터의 생성자에서 인플레이터 객체를 생성? 아니면 fill_parent가 동적 인 높이에서만 작동하지 않습니까?
답변 해 주셔서 감사합니다. 그러나 구분선은 행을 세로로 채우지 않습니다. 이 동작이 버그인지 아니면 내가 누락 된 다른 것이 있는지 확실하지 않습니다. 다른 아이디어? –