I am in a condition that my app needs TabHost using only java code not the xml . But i need the TabHost height to be set 20dp. Is that possible using only java code?
Please help?
I am in a condition that my app needs TabHost using only java code not the xml . But i need the TabHost height to be set 20dp. Is that possible using only java code?
Please help?
I think this can help you:
TabHost tabHost = new TabHost(context);
tabHost.setLayoutParams(new ViewGroup.LayoutParams(YOUR_WIDTH_HERE, YOUR_HEIGHT_HERE));
You can use ViewGroup.LayoutParams.FILL_PARENT or WRAP_CONTENT or MATCH_PARENT
Try this. hope it may be helpful
tabHost.getTabWidget().getChildAt(index).getLayoutParams().height =(int) height;
For any view you can provide custom width and heiht by providing LayoutParams
. All sizies in LayoutParams set in pixels. If you want to use dp
- use this code:
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, getResources().getDisplayMetrics());