在Android的标签布局段落创建行分隔 [英] Creating line dividers in Android tab layout paragraphs

查看:217
本文介绍了在Android的标签布局段落创建行分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,第一篇文章,并在Android的编程菜鸟,但愿意学习!基本上,我已经从这里

Hey all, first post and a noob in Android programming, but willing to learn! Basically I've taken the Google sample of a tab layout from here

我发现的方法很容易与每个选项卡中的文本创建标签,但我试图让这个当选择一个标签,我想下面列出的文本被分割线隔开。所以这一条线的每个段落之间的分裂,但是我无法这样做。这是我到目前为止有:
main.xml中:

I found that method to be very easy to create tabs with text within each tab, but I'm trying to make it so that when a tab is selected, I want the text listed below to be separated by a dividing line. So that a line is dividing between each paragraph, however I'm having trouble doing this. This is what I have so far: 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文件中的信息:

Here is the info in the java file:

  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中我能得到这是第一选项卡的第一行的上的第一线,但这是第一选项卡的第二行是表示在第一行上,并且在所有其他标签。
在此先感谢您的帮助,希望与我所获得的知识,我可以帮助别人的未来。

In main.xml I can get "this is the FIRST line of the 1st tab" on the first line, but "this is the SECOND line of the 1st tab" is showing up in the first line, and in all other tabs. Thanks in advance for any help, hopefully with my gained knowledge I can help others in the future.

推荐答案

如果你只是想一个分隔符(线,将该区域分为两部分),你可以使用下面的code在布局XML文件;

If you simply want a separator (line dividing the area into two sections), you can use the following code in your layout XML file;

<View   android:id="@+id/firstDivider"
        android:layout_height="2dp"
        android:layout_width="fill_parent"
        android:background="#000080" />

以上code会产生2DP厚,深蓝色的护栏。
增加 layout_height 将增加分的厚度。

恢复任何查询。

这篇关于在Android的标签布局段落创建行分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆