पर स्क्रॉल बार मेरे पास CustomComponent
कक्षा है जो ViewGroup
फैली हुई है।कस्टम व्यू ग्रुप
CustomComponent
की
स्रोत कोड:
public class CustomComponent extends ViewGroup {
private static final String LOGTAG = "CustomComponent";
private List<MenuItem> items;
private Context context;
private int screenWidth;
private int screenHeight;
private int cellWidth;
private int cellHeight;
private int duration;
private int space=7;
public CustomComponent(Context context) {
super(context);
this.context=context;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Log.v(LOGTAG, "on Measure called");
screenWidth = MeasureSpec.getSize(widthMeasureSpec);
screenHeight = MeasureSpec.getSize(heightMeasureSpec);
cellHeight=screenHeight/AppConstants.HEIDHTCELLSCOUNT;
cellWidth=screenWidth/AppConstants.WIDTHCELLSCOUNT;
duration= cellHeight*2;
super.onMeasure(widthMeasureSpec, heightMeasureSpec+duration);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
Log.v(LOGTAG, "onLayout called");
int childCount = this.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
child.layout(items.get(i).getLeft(),items.get(i).getTop(),items.get(i).getRight(), items.get(i).getBottom());
}
}
public List<MenuItem> getItems() {
return items;
}
public void setItems(List<MenuItem> items) {
this.items = items;
}
}
XML लेआउट:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/menu_layout"
android:scrollbars="vertical">
<<package name>.CustomComponentandroid:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/menu_component"
android:scrollbars="vertical"
android:fadingEdge="vertical"/>
</LinearLayout>
मैं इस ViewGroup
को लंबवत स्क्रॉल जोड़ने की जरूरत है। कृपया मदद करें, मुझे नहीं पता कि इस समस्या को कैसे हल किया जाए।
[यहां] से कोड (http://code.google.com/p/android-masonry/source/checkout) मेरे लिए काम किया आप सूट करने के लिए तुम्हारा – almuneef
हाय Natali कुछ संपादन की आवश्यकता हो सकती, मुझे पता है इस सवाल है बहुत पुराना लेकिन क्या आपको इसका समाधान मिला। यदि आपको यह मिल गया है तो इसे पोस्ट करें। मैं इसी तरह की स्थिति में फंस गया हूं – silwar
हैलो। मुझे इसके लिए कोई समाधान नहीं मिला, इसलिए मैंने कस्टम दृश्यों (रंगीन बक्से) के साथ सापेक्ष लेआउट का उपयोग बच्चे के विचारों के रूप में किया। – Natali