如何添加父对齐的标签TabWidget?
-
26-09-2019 - |
题
我写Java代码来创建一个tabs.i已经做that.but现在我想的标签控件是在菜单的屏幕的下部希望这将加入这个代码achived。 android:layout_alignParentBottom="true"
让我知道如何添加此coding.i希望类似的外观像这样的 http://android-pro.blogspot.com/2010/08/iphone-like-tab-bar-in-android.html
TabHost tabHost =新TabHost(本);
tabHost.setLayoutParams(
new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
RelativeLayout rl=new RelativeLayout(ContactManager.this);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, android.R.id.tabs);
rl.setLayoutParams(rlp);
tabHost.addView(rl);
TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);
rl.addView(tabWidget, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);
frameLayout.setPadding(0, 55, 0, 0);
rl.addView(frameLayout, new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tabHost.setup();
解决方案
与XML做你的布局就容易得多。您将需要定制的标签图像,因为股票的人不会在屏幕右下方的样子。
不隶属于 StackOverflow