I have made a Custom ViewGroup. Detail about this Custom ViewGroup is found here from my earlier question. The problem I am facing here is , whenever I try to add buttons in the LinearLayout that is inside the custom Viewgroup, the buttons never get shown. I have tried many things but the button is never displayed, do I have to do something in the custom viewgroup, I even tried inflating the button but still did not work.
Code for Custom ViewGroup:
public class RootViewLayout extends ViewGroup {
private View mDrawView;
private View mSlideView;
private int mTop;
private int mDragRange;
public RootViewLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onFinishInflate() {
mDrawView = findViewById(R.id.content_frame_white);
mSlideView = findViewById(R.id.slide_frame);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom){
bringChildToFront(mDrawView);
mDrawView.layout(0, 0, right, bottom);
mSlideView.layout(0, 0, right/2, bottom);
}
}
and the XML :
<com.example.drawapp.RootViewLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Root_View_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.example.drawapp.DrawView
android:id="@+id/content_frame_white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/whitepaperwithcoffeestain">
</com.example.drawapp.DrawView>
<LinearLayout
android:id="@+id/slide_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/slidebackgrd"
android:orientation="vertical">
<Button
android:id="@+id/pen"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:background="@drawable/pic"/>
</LinearLayout>
</com.example.drawapp.RootViewLayout>