2017-02-21 11 views
0

제발 도와주세요! 나는 너무 길다! 이 시간을 보냈다. 미리 감사드립니다 !!그룹 지시 기호를 변경하는 방법 xamarin andriod

는 문제 :는 내가 groupindicator을 변경했지만 이미지가 수평으로 늘어 나는 그것을 고칠 수

내가 시도하는 것 : 그래서 나는 9 패치 이미지에 이미지 중 하나를 변환 시도 그러나 xamarin은 그것을 발견하지 못했습니다. indicatorbounds (0,5)를 설정했지만 화살표가 표시되지 않습니다. 너무 길어서 어떻게 이미지와 함께 expanablelistview 화살표 (groupindicator)를 바꿀 수 있습니까? 그런 다음 이미지가 늘어나지 않지만 고정 된 크기 지정할 수 있습니까? 설정 선택기 xml로도 놀았지만 아무 것도 작동하지 않는 것 같습니다!

미리 감사드립니다.

settings_selector.xml

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item 
     android:left="5dp" 
    android:right="5dp" 
    android:top="5dp" 
    android:bottom="5dp" 
     android:drawable="@drawable/uparrow" 
     android:state_expanded="true" /> 

    <item 
     android:left="11dp" 
    android:right="11dp" 
    android:top="12dp" 
    android:bottom="12dp" 
     android:drawable="@drawable/downarrow" /> 

</selector> 

Page.axml I는 해당 이미지가 연신되지 화상으로 expanablelistview 화살표 (groupindicator)를 대체 할 수있는 방법

`{<?xml version="1.0" encoding="utf-8"?> 
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/myExpandableListview" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:groupIndicator="@drawable/settings_selector" 
    android:layout_height="match_parent" 

    />} 
+0

내 대답을 확인 했습니까? 어떤 문제? –

답변

0

하지만 고정 된 크기 내가 지정할 수 있니?

그룹 표시기의 아이콘 이미지는 항상 늘리며 대개 상단 및 하단 모두에서 신축성있는 픽셀 만 포함하는 9 패치 이미지로 문제를 해결할 수 있습니다. 그러나 9 개의 패치 이미지가 효과가 없을 때 이미지 리소스를 사용하기를 원한다면 이미지의 늘어짐 문제를 해결하는 쉬운 방법은 ExpandableListViewandroid:groupIndicator="@null"을 설정하는 것입니다.

그런 다음 목록 그룹에 대한 레이아웃 ExpandableListView의 (헤더)에서 수동으로 예를 들어 ImageView을 추가

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:id="@+id/indicator" 
     android:src="@drawable/downicon" /> 
    <TextView 
     android:id="@+id/DataHeader" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="DataHeader" 
     android:layout_margin="2dp" 
     android:textStyle="bold" 
     android:paddingStart="50dp" 
     android:paddingLeft="50dp" /> 
</LinearLayout> 

을 마지막으로 코드에서 뒤에이 같은 예를 들어 당신의 ExpandableListViewGroupClick 이벤트를 구독 :

를 이 데모의
protected override void OnCreate(Bundle bundle) 
{ 
    base.OnCreate(bundle); 

    // Set our view from the "main" layout resource 
    SetContentView(Resource.Layout.Main); 

    var listView = FindViewById<ExpandableListView>(Resource.Id.myExpandableListview); 
    listView.SetAdapter(new ExpandableDataAdapter(this, Data.SampleData())); 
    listView.GroupClick += ListView_GroupClick; 
} 

private void ListView_GroupClick(object sender, ExpandableListView.GroupClickEventArgs e) 
{ 
    var view = e.ClickedView; 
    var indicator = view.FindViewById<ImageView>(Resource.Id.indicator); 
    if (e.Parent.IsGroupExpanded(e.GroupPosition)) 
    { 
     e.Parent.CollapseGroup(e.GroupPosition); 
     indicator.SetImageResource(Resource.Drawable.downicon); 
    } 
    else 
    { 
     e.Parent.ExpandGroup(e.GroupPosition); 
     indicator.SetImageResource(Resource.Drawable.upicon); 
    } 
} 

렌더링 이미지 :

enter image description here