2016-08-09 10 views
0

私自身のアンドロイドアプリでタブを使いたいのですが、問題があります。私は右側にTabWidgetの整列を行うようにして、最初のタブヘッダーが右側に配置されるようにします。私は、TabWidgetの重力を右に設定し、LinearLayoutの入れ子になったTabWidgetを設定し、重力を右に設定するようなWebでいくつかの解決法を見つけましたが、それらは機能しませんでした。Android右揃えTabWidget

enter image description here

嘆願誰かが私を助け:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="ir.andrun.tabbased.Main" 
    tools:showIn="@layout/app_bar_main"> 

    <TabHost 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/tabHost"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <HorizontalScrollView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:scrollbars="none"> 
       <TabWidget 
        android:id="@android:id/tabs" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

         <TextView 
          android:tag="tab0" 
          android:text="Tab 1" 
          android:layout_width="wrap_content" 
          android:layout_height="fill_parent" /> 
         <TextView 
          android:tag="tab1" 
          android:text="Tab 2" 
          android:layout_width="wrap_content" 
          android:layout_height="fill_parent" /> 
         <TextView 
          android:tag="tab2" 
          android:text="Tab 3" 
          android:layout_width="wrap_content" 
          android:layout_height="fill_parent" /> 

       </TabWidget> 
      </HorizontalScrollView> 
      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <LinearLayout 
        android:id="@+id/linearLayout" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 

        <TextView 
         android:text="Tab 1" 
         android:layout_width="wrap_content" 
         android:layout_height="fill_parent" /> 

       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/linearLayout2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 

        <TextView 
         android:text="Tab 2" 
         android:layout_width="wrap_content" 
         android:layout_height="fill_parent" /> 

       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/linearLayout3" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 

        <TextView 
         android:text="Tab 3" 
         android:layout_width="wrap_content" 
         android:layout_height="fill_parent" /> 

       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 
</RelativeLayout> 

これが結果です:

は、これは私のコードです。

タンク。

答えて

0

オプション0:android:gravity="end"

オプション1にtabhostを設定してみてください:android:layout_alignRight="true"またはandroid:layoutParentEnd="true"

オプション2にtabhostを設定してみてください:tabhost

前に係-上部空間を追加します。
<!-- Take up space --> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="0.1"/> 

ご希望のものが1つあります。