2013-03-16 106 views
3

我在ActionBar中有5個選項卡,我已經設計了它們來刪除填充並減少選項卡上的文本大小,但無論如何,選項卡欄都會滾動幾個像素方向。我的標籤都很合適,所以我不希望它們能夠來回滑動,即使有一點點。防止Android ActionBar滾動

如何防止ActionBar選項卡被滾動?

我在我的項目中使用ActionBarSherlock,這樣我就可以在不同版本的Android上擁有統一的UI。

正如你在下面看到的,有很多空間,所以我沒有看到任何理由它應該能夠擺動/滾動時,所有的標籤都很好。

enter image description here

回答

0

有沒有祕密,它只是意味着有太多的標籤在你的ActionBarSherlock和/或它們的寬度太大。

這裏是標籤佈局具有圖像和文本的爲例:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/tab_item" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="horizontal" 
    android:paddingTop="8dp" > 

    <ImageView 
     android:id="@+id/tab_icon" 
     android:layout_width="28dp" 
     android:layout_height="28dp" 
     android:layout_marginRight="4dp" /> 

    <TextView 
     android:id="@+id/tab_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:ellipsize="marquee" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:scrollHorizontally="true" 
     android:singleLine="true" 
     android:textColor="@android:color/white" 
     android:textSize="12sp" /> 

</LinearLayout> 

您使用的是TabAdapter?也許你可以發佈你的代碼,看看是否有什麼東西在上面?