2017-02-21 4 views
0

ご連絡ください! 私はとても迷っています!これを直すのに時間を費やした! ありがとうございます!groupindicator arrow xamarin andriodを変更するには

問題:私はgroupindicatorを変更したが、画像は、私が試してみました何水平に伸びていると私はそれを

を修正することはできません。だから私は、9パッチ画像へのイメージの1つを変換しようとした をxamarinはそれを見つけることができませんでした。 indicatorbounds(0,5)を設定しようとしましたが、矢印が表示されません。 私は失われています。どのようにしてイメージと拡大可能リストビュー(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