Custom Linearlayout, Child Is Not Viewing
I'm creating my Cell view by extending LinearLayout, it's creating parent, but not showing children. I really couldn't find the problem? Cell cell = new Cell(ctx); cell.setLetterAn
Solution 1:
I had to override onLayout
method.
onLayout(boolean paramBoolean, intleft, int top, intright, int bottom)
@OverrideprotectedvoidonLayout(boolean paramBoolean, int left, int top, int right, int bottom)
{
intwidthOfCell= right - left;
getChildAt(0)
.layout(1,
1,
widthOfCell,
widthOfCell
);
}
Solution 2:
I think that the problem is your Textview. You have not added the textview to your linearlayout. Change your method init
void init(Context context) {
LayoutInflater.from(context).inflate(R.layout.view_cell, this);
text = (TextView) this.findViewById(R.id.text);
this.addView(text);
this.setBackgroundColor(Color.parseColor("#ffffff"));
}
Post a Comment for "Custom Linearlayout, Child Is Not Viewing"