1
私は最初の子がGridviewである拡張可能なリストを持っています。ここで私はグリッドビューの高さカットの問題があった。私はこの解決方法を使って解決しました:Gridview height gets cut。GridViewアイテムがスクロールしていません。展開可能リスト
新しい問題が発生しました。固定高さの下で、gridviewアイテムをスクロールできません。私はグリッドビュー項目が動的に成長する可能性があるので、ここでスクローラーを追加する必要があります。
私は通常のgridviewでこれを行うことができますが、この厄介な問題を展開可能なリストビューで示しています。
コード:拡張可能なリストのカスタムレイアウトで
<ExpandableListView
android:id="@+id/Explst"
android:layout_height="400dp"
android:transcriptMode="disabled"
android:layout_width="match_parent"
android:layout_marginTop="0.5dp" />
GridViewの:
<mynamespace.ExpandableHeightGridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="20dp"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth"
android:isScrollContainer="false"
android:gravity="center" />
カスタムexpandableheightgridview.cs
mynamespace
{
public class ExpandableHeightGridView :GridView
{
bool _isExpanded = false;
public ExpandableHeightGridView (Context context) : base (context)
{
}
public ExpandableHeightGridView (Context context, IAttributeSet attrs) : base (context, attrs)
{
}
public ExpandableHeightGridView (Context context, IAttributeSet attrs, int defStyle) : base (context, attrs, defStyle)
{
}
public bool IsExpanded {
get { return _isExpanded; }
set { _isExpanded = value; }
}
protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
{
if (IsExpanded) {
int expandSpec = MeasureSpec.MakeMeasureSpec (View.MeasuredSizeMask, MeasureSpecMode.AtMost);
base.OnMeasure (widthMeasureSpec, expandSpec);
var layoutParameters = this.LayoutParameters;
layoutParameters.Height = this.MeasuredHeight;
} else {
base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
}
base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
どれ提案/ヒント/リンクはかなりあります。 私はxamarin.android C#でこれを試していますが、JavaのAndroidソリューションも役立ちます。
ありがとうございます。
はい私はすでにそれを行いました。 Expandは問題なく動作しています。しかし、そのグリッド項目のスクロールを設定することはできません。 – Suchith