Ich möchte Tabs in meiner eigenen Android-App verwenden, aber es gibt ein Problem für mich. Ich versuche, die TabWidget-Ausrichtung auf der rechten Seite so zu machen, dass der erste Tab-Header auf der rechten Seite platziert wird. Ich finde eine Lösung im Web, wie TabWidget gravity nach rechts zu setzen, TabWidget in LinearLayout zu verschachteln und gravity nach rechts zu setzen, aber sie haben nicht funktioniert.Android Right Align TabWidget
Dies ist mein Code:
<?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>
Dies ist Ergebnis:
Pleas mir jemand helfen.
Tanks.
Es ist cool und schön tanx. Wie kann ich die richtige Ausrichtung vornehmen? – RedFlow