2012-06-18 3 views
1

현재 두 번째 GroupView 목록에 위의 제목을 포함 할 수 있도록 ExpandableListView을 정의했습니다. 그러나 이것은 확장 화살표의 흐름이 텍스트와 정렬되지 않고보기의 가운데에 정렬되어 사용자에게 호소력을 발휘합니다. 누구든지이 표정을 더 매력적으로 보이기 위해 할 수있는 것에 대해 어떤 하위 결정을 가지고 있습니까? 두 번째 그룹 뒤에 헤더가 있어야합니다.확장 가능 목록 GroupView의 화살표를 가운데 맞춤되지 않은 텍스트와 정렬해야합니다.

enter image description here

이 코드는 내 사용자 지정 어댑터를 내 GroupView를 설정하는 것입니다.

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, 
     ViewGroup parent) { 

    TextView groupTitle = null; 
    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View v = null; 
    if(groupPosition == 1){ 
     v = layoutInflater.inflate(R.layout.custom_first_major_language_group_row, null); 
    } else { 
     v = layoutInflater.inflate(R.layout.custom_language_group_row, null); 
    } 
    groupTitle = (TextView) v.findViewById(R.id.text_element); 
    String myText = this.getGroup(groupPosition).toString(); 
    groupTitle.setText(myText); 

    return v; 
} 

custom_language_group_row.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
    <TextView 
     android:id="@+id/text_element" 
     android:layout_width="fill_parent" 
     android:layout_height="48dip" 
     android:textSize="20sp" 
     android:textColor="#fff" 
     android:layout_marginLeft="48dip" 
     android:gravity="center_vertical" 
     android:text = "Language Group Name"/> 
</RelativeLayout> 

custom_first_major_language_group_row.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
     <TextView 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Major Languages" 
     android:textColor="#000" 
     android:background="#fff" 
     android:id="@+id/majorLanguageTitle" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_centerHorizontal="true"></TextView> 

    <TextView 
     android:id="@+id/text_element" 
     android:layout_width="fill_parent" 
     android:layout_height="48dip" 
     android:textSize="20sp" 
     android:textColor="#fff" 
     android:layout_marginLeft="48dip" 
     android:gravity="center_vertical" 
     android:layout_below="@+id/majorLanguageTitle" 
     android:text = "Language Group Name"/> 
</RelativeLayout> 

당신은으로 정렬 내가 드롭 다운 화살표를 얻을 수있는 방법의 어떤 아이디어가있는 경우 텍스트 그것은 많이 감사하겠습니다.

+0

동일한 문제가 있습니다 ... 나는 귀하의 게시물을 볼 때 너무 흥분했습니다. 나는 대답을 얻을 것 같았다. –

답변

0

제 대답은 다소 답답합니다. 그 문제가 있었지만 광산 텍스트가 약 4-5dp (테스트 후)만큼 중심에 있지 않다는 것을 알게되었습니다. 따라서 펼치기/접기 이미지를 정확하게 가운데로 이동하는 대신 텍스트를 가운데에 놓은 다음 5dp의 텍스트보기에 아래쪽 여백을 추가합니다. 이제 내 textview가 펼치기/접기 이미지와 매우 비슷하게 보입니다.

선호하는 솔루션은 아니지만 나에게 도움이되었습니다.

관련 문제