【发布时间】:2011-07-06 22:08:40
【问题描述】:
我想开发一个像 Dolphin HD 一样模拟标签浏览的应用程序。下面是我用来创建 UI 的 XML 文件。
我的查询是,
- 我无法获得像 dolphin HD 这样的固定尺寸标签。
- 当我创建了大约 4-5 个选项卡后,现在我想以编程方式将焦点设置到新选项卡并将其滚动到当前视图。
类似的查询已发布在以下链接中,但它仍然无法正常工作...... Android - Programmatic scrolling of TabWidget
在添加新选项卡方法中,我尝试插入上面链接中提到的以下行……。但是没用……
tabHost.setFocusableInTouchMode(true);
tabHost.setCurrentTab(z);
tabHost.setFocusable(true);
//Vinod
for ( i = 0; i < z; i++) {
getTabWidget().getChildAt(i).setFocusableInTouchMode(true);
}
XML 文件:-
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<HorizontalScrollView android:layout_width="420px"
android:id="@+id/tab1"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="10px"
android:layout_height="wrap_content"
android:tag="tabPane">
</TabWidget>
</HorizontalScrollView>
<ImageButton
android:background="@android:color/transparent"
android:layout_marginTop="10px"
android:id="@+id/add_btn"
android:layout_height="70px"
android:layout_width="70px"
android:src="@android:drawable/ic_menu_add"
android:layout_toRightOf="@id/tab1"/>
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/address_bar"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10px"
android:layout_width="fill_parent"
android:layout_height="70px"/>
</RelativeLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp" />
</LinearLayout>
</TabHost>
【问题讨论】:
标签: android-tabhost