2013-05-30 39 views
1

我正在開發一個android應用程序,我在其中使用tablerow與viewpagerAdapter。 我需要添加一個指標,當用戶從一個頁面滑動到另一個頁面時,我想添加一條水平線,如下圖所示。onpling指標在viewpager android

http://imgur.com/ZTD7w0e

我嘗試添加圖像(水平行),這適用於所有的3個標籤,而不是僅僅TAB1

下面是代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/white" 
android:orientation="vertical" > 

<TableLayout 
    style="@style/layout_f_w" 
    android:stretchColumns="*" > 

    <TableRow 
     android:id="@+id/tableRow1" 
     style="@style/layout_wrap" 
     android:background="#dddddd" 
     android:clickable="true" > 

     <!-- First Tab --> 

     <LinearLayout 
      android:id="@+id/first_text" 
      style="@style/layout_f_w" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/textView1" 
       style="@style/text_title" 
       android:text="Tab1" /> 
     </LinearLayout> 

      <LinearLayout 
      android:id="@+id/second_text" 
      style="@style/layout_f_w" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/textView1" 
       style="@style/text_title" 
       android:text="Tab2" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/third_text" 
      style="@style/layout_f_w" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/textView1" 
       style="@style/text_title" 
       android:text="Tab3" /> 
     </LinearLayout> 
    </TableRow> 
</TableLayout> 

<include 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/indicator" /> 

<ImageView 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/h_line" /> 

<android.support.v4.view.ViewPager 
    android:id="@+id/viewPager" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

由於!

+0

哪裏是像...嘗試使用相對佈局..並同時設置水平線。然後根據頁面移動設置alpha(0)或者一個。如果你可以顯示水平線..我可以更好地解釋你.. – amalBit

+0

@amal:圖像被添加above.You還可以點擊鏈接:http://imgur.com/ZTD7w0e – DevAndro

+0

好吧... 。現在在每個標籤下面放置三條水平線,並將其可見性消除。然後從相應的頁面被選中時將它們設置爲可見。 – amalBit

回答

1
+0

我已經使用了它。它有點複雜,選項卡中的文本更長,它將添加到下一行。因此,我嘗試了不同的方式。除指示符外,它工作正常。 – DevAndro