1
我正在編寫java代碼來創建一個tabs.i已經完成了。但是現在我希望tab小部件位於screen.i的下部,希望通過添加此代碼可以實現這一點。 android:layout_alignParentBottom="true"
讓我知道如何添加這個編碼。我想要類似這樣的樣子http://android-pro.blogspot.com/2010/08/iphone-like-tab-bar-in-android.html如何爲TabWidget選項卡添加父對齊?
TabHost tabHost = new TabHost(this);
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();
謝謝!我已經完成了這一個,並得到了輸出。 – Ads 2010-11-23 12:33:06