Android-自定义TabHost布局或按钮?
我想定制如下布局:触摸每个选项卡(新闻/视频)将显示每个页面的内容 我不确定到底应该使用什么小部件:2个按钮还是TabHost 谢谢你的帮助Android-自定义TabHost布局或按钮?,android,android-layout,button,android-tabhost,Android,Android Layout,Button,Android Tabhost,我想定制如下布局:触摸每个选项卡(新闻/视频)将显示每个页面的内容 我不确定到底应该使用什么小部件:2个按钮还是TabHost 谢谢你的帮助 简单的方法:setContentView但感觉不好 另一种方法:一个带有2个单选按钮的自定义tabhost <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
简单的方法:setContentView但感觉不好 另一种方法:一个带有2个单选按钮的自定义tabhost
<?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="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:background="@drawable/home01_23"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="50dp"></ImageView>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.0"
android:visibility="gone"/>
<RadioGroup
android:id="@+id/main_radio"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radio_1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_gravity="bottom"
android:checked="true"
android:layout_marginRight="5dp"
android:text=""/>
<RadioButton
android:id="@+id/radio_2"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_gravity="bottom"
android:checked="false"
android:layout_marginRight="5dp"
android:text=""/>
</RadioGroup>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_below="@+id/main_radio"
android:layout_height="fill_parent">
</FrameLayout>
</RelativeLayout>
</TabHost>
我做了一个决定,只是不想每次都处理这些事情。。。如果需要,您可以使用它。您能给我xml代码吗?我尝试使用一个带有2个标签的TabHost,但结果和这张图片不完全一样。我已经更新了,试试看。谢谢你,JaveZh。在我的例子中,我使用2个按钮,而不是您使用的RadioGroup。我将使用您的库来自定义我的布局。谢谢你的帮助。