在Android Tab布局段落中创建线路分隔线
题
大家好,第一篇文章和Android编程中的菜鸟,但愿意学习!基本上,我从 这里
我发现该方法非常容易在每个选项卡中使用文本创建标签,但是我试图制作它,以便选择选项卡时,我希望下面列出的文本被分隔线分开。这样一条线在每个段落之间分开,但是我很难做到这一点。这就是我到目前为止所拥有的:main.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableRow>
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the FIRST line of the 1st tab" />
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the SECOND line of the 1st tab" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is First line of the 2nd tab" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the First line of the 3rd tab" />
<TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="This is the First line of the 4th tab." />
</TableLayout>
</FrameLayout>
这是Java文件中的信息:
public class HelloTabWidget extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));
mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("TAB 4").setContent(R.id.textview4));
mTabHost.setCurrentTab(0);
}
}
在main.xml中,我可以在第一行上获得“这是第一行的第一行”,但是“这是第一行的第二行”在第一行和所有其他选项卡中显示。在此先感谢您的任何帮助,希望有了我获得的知识,我将来可以帮助他人。
解决方案
如果您只需一个分离器(将区域分为两个部分),则可以在布局XML文件中使用以下代码;
<View android:id="@+id/firstDivider"
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#000080" />
上面的代码将产生2DP厚的海军蓝色分层。增加 layout_height
会增加分隔线的厚度。
恢复任何查询。
不隶属于 StackOverflow