2011-06-08 96 views
0

大家好,這是我的標籤佈局代碼到Android我希望他們到scrren的底部目前它顯示我在屏幕安卓tabwidget需要幫助

main.xml中

的頂部
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_alignParentBottom="true" 
    android:gravity="bottom"> 
    <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <LinearLayout android:orientation="vertical" 
      android:layout_width="fill_parent" android:layout_height="fill_parent"> 
      <HorizontalScrollView android:scrollbars="none" 
       android:layout_width="fill_parent" android:layout_height="wrap_content"> 
       <TabWidget android:id="@android:id/tabs" 
        android:layout_alignParentBottom="true" android:layout_width="fill_parent" 
        android:layout_height="wrap_content" /> 
      </HorizontalScrollView> 
      <FrameLayout android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" android:layout_height="fill_parent" 
       android:padding="5dp" /> 
     </LinearLayout> 
    </TabHost> 
</LinearLayout> 

tab.xml

<?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="@drawable/tab_background_selector" android:gravity="center" 
    android:orientation="vertical" android:padding="5dp" 
    android:layout_alignParentBottom="true" > 
    <ImageView android:id="@+id/tab_icon" android:layout_width="30dp" 
     android:layout_height="30dp" android:scaleType="fitCenter" /> 
    <TextView android:id="@+id/tab_text" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:singleLine="true" 
     android:textStyle="bold" android:gravity="center_horizontal" 
     android:textSize="10sp" android:padding="3dip" android:ellipsize="marquee" 
     android:textColor="@drawable/tab_text_selector" 
     android:layout_alignParentBottom="true" /> 
</LinearLayout> 

這是我的活動類 TestActivity.java

import android.app.TabActivity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.widget.ImageView; 
import android.widget.TabHost; 
import android.widget.TextView; 
import android.widget.TabHost.TabSpec; 

public class TestActivity extends TabActivity { 
     @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.maiin); 
     final TabHost tabHost = (TabHost) getTabHost(); 
      tabHost.addTab(createTab(MobiintheMorningActivity.class, 
        "Welcome", "Welcome", R.drawable.icon));  

      tabHost.setCurrentTab(0); 
      tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 85; 
      } 

     private TabSpec createTab(final Class<?> intentClass, final String tag, 
       final String title, final int drawable) 
     { 
      final Intent intent = new Intent().setClass(this, intentClass); 

      final View tab = LayoutInflater.from(getTabHost().getContext()). 
       inflate(R.layout.tab, null); 
      ((TextView)tab.findViewById(R.id.tab_text)).setText(title); 
      ((ImageView)tab.findViewById(R.id.tab_icon)).setImageResource(drawable); 

      return getTabHost().newTabSpec(tag).setIndicator(tab).setContent(intent); 
     } 
    } 

這裏我用android:layout_alignParentBottom="true",但完全沒有影響我應該怎麼辦?我失蹤了什麼?在此先感謝:Pragna

+0

-1海報顯然沒有問這個人之前搜索過類似的問題。海報爲這個問題定義了一個幾乎沒用的標題(標題應該是「如何在底部顯示標籤而不是在頂部?」,這恰好是穆罕默德給出的解決方案的標題)。 – cdhabecker 2011-08-03 03:37:06

回答

0

請參閱solution將標籤欄放在底部。

0

變化的FrameLayout在你xml.I位置和widget認爲我幫你