我已经创建了xml文件并完成了我的项目
现在我想在我的xml文件中添加底部标签栏
这是我的xml文件代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/main_bg"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
>
<!-- Logo -->
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="40dip" android:layout_alignParentTop="true"
android:background="@drawable/tab_bar" android:id="@+id/rel_jobDesc">
<!-- <Button android:id="@+id/option"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/skills"
android:layout_centerVertical="true" android:text=""
></Button>
-->
<TextView android:layout_width="wrap_content" android:id="@+id/txt_SEARCH_TITLE"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:text="Job Search" android:textStyle="bold" android:textSize="20dip"
android:textColor="#fff"></TextView>
<Button android:id="@+id/btnAboutus"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:background="@drawable/draw"
android:layout_centerVertical="true" android:text="About Us"
></Button>
<Button
android:id="@+id/option"
android:background="@drawable/hamburger"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/l1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/rel_jobDesc" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/logo"
android:layout_marginTop="20dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp" >
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="55dip" android:layout_marginLeft="2dip"
android:layout_marginRight="2dip">
<!--JOB DESCRIPTION -->
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txt_JOB_DESCRIPTION"
android:layout_marginLeft="20dip" android:text="Job Description:"
android:layout_marginTop="20dip"
android:textStyle="bold"
android:textSize="14dip" android:textColor="#000000"
></TextView>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/edit_JOB_DESCRIPTION"
android:layout_toRightOf="@+id/txt_JOB_DESCRIPTION"
android:maxLines="1"
android:background="@android:drawable/editbox_background"
android:singleLine="true"
android:layout_marginTop="10dip" android:layout_marginRight="20dip"
></EditText>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txt_JDESCRIPTION"
android:layout_marginLeft="45dip" android:text="(Job title, industry, keywords)"
android:textSize="12dip" android:textColor="#4a596e"
android:layout_below="@+id/edit_JOB_DESCRIPTION"
android:layout_centerInParent="true"></TextView>
<!-- -->
<!--LOCATION -->
<TextView
android:id="@+id/txt_JOB_LOCATION"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_JDESCRIPTION"
android:layout_marginLeft="20dip"
android:layout_marginTop="50dip"
android:layout_toLeftOf="@+id/btn_SEARCH"
android:text="Location: "
android:textColor="#000000"
android:textSize="15dip"
android:textStyle="bold" >
</TextView>
<EditText
android:id="@+id/edit_JOB_LOCATION"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edit_JOB_DESCRIPTION"
android:layout_below="@+id/txt_JDESCRIPTION"
android:layout_marginRight="20dip"
android:layout_marginTop="40dip"
android:background="@android:drawable/editbox_background"
android:maxLines="1"
android:singleLine="true" >
</EditText>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/txt_JLOCATION"
android:layout_marginLeft="45dip" android:text="(City, State, Zip)"
android:textSize="12dip" android:textColor="#4a596e"
android:layout_below="@+id/edit_JOB_LOCATION"
android:layout_centerInParent="true"></TextView>
<!-- -->
<!-- JOB ID -->
<!-- -->
<!-- SEARCH BUTTON -->
<Button
android:id="@+id/btn_SEARCH"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_JLOCATION"
android:layout_centerInParent="true"
android:layout_marginTop="55dip"
android:background="@drawable/draw"
android:text=" Search " >
</Button>
<!-- -->
</RelativeLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
请建议我如何在我的xml文件中添加底部标签栏
任何帮助都是赞赏的
先谢谢
答案 0 :(得分:2)
您可以像这样添加 -
<?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_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</RelativeLayout>
</TabHost>
在上面的代码android:layout_alignParentBottom=”true”
用于将其与底部对齐。
在活动类 -
Intent intent;
intent = new Intent().setClass(this, FirstActivity.class);
spec = tabHost.newTabSpec("First").setIndicator("First")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SecondActivity.class);
spec = tabHost.newTabSpec("Second").setIndicator("Second")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, ThirdActivity.class);
spec = tabHost.newTabSpec("Third").setIndicator("Third")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, FourthActivity.class);
spec = tabHost.newTabSpec("Fourth").setIndicator("Fourth")
.setContent(intent);
tabHost.addTab(spec);
答案 1 :(得分:0)
您是否尝试为android:layout_alignParentBottom="true"
添加TabWidget
?
<?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_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</RelativeLayout>
</TabHost>
答案 2 :(得分:0)
使用标签主机获取应用中的标签栏。
答案 3 :(得分:0)
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
这是在底部添加tabhost,这是你想要的。 如果你想要这个wat,请接受答案。 如果您有任何疑问,请ping我。