Note that there are some explanatory texts on larger screens.

plurals
  1. POScroll bar to custom ViewGroup
    primarykey
    data
    text
    <p>I have <code>CustomComponent</code> class which extends <code>ViewGroup</code>.</p> <p>Source code of <code>CustomComponent</code>:</p> <pre><code> public class CustomComponent extends ViewGroup { private static final String LOGTAG = "CustomComponent"; private List&lt;MenuItem&gt; 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 &lt; 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&lt;MenuItem&gt; getItems() { return items; } public void setItems(List&lt;MenuItem&gt; items) { this.items = items; } } </code></pre> <p>Xml layout:</p> <pre><code>&lt;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"&gt; &lt;&lt;package name&gt;.CustomComponentandroid:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/menu_component" android:scrollbars="vertical" android:fadingEdge="vertical"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>I need to add vertical scroll to this <code>ViewGroup</code>. Please help, I have no idea how to solve this problem. <img src="https://i.stack.imgur.com/7D4l0.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload