wie die Laschen in dem unteren Teil des Bildschirms in Android gesetzt?
-
18-09-2019 - |
Frage
Ich arbeite an tabactivity.
ich möchte meine TabWidget unter dem tabcontent (framelayout) zeigen.
ich es durch Einstellen der tabwiget Registerkarte Attribut als
getanandroid:gravity="bottom"
aber die framelayout kann nicht mit den Registerkarten ausrichten.
dh die Laschen am unteren Rand des Bildschirms angezeigt und überlappen sich die framelayout
, wie das zu tun? wenn eine gewisse Höhe Wert auf den framelayout legen Sie es nicht für alle Bildschirme von Android optimiert. was kann ich machen? irgendeine Idee???
Lösung
oder benutzen Sie einfach einen benutzerdefinierten eine von: http://code.google.com/p/androidtabs/
es erlaubt Laschen an der Unterseite
Andere Tipps
Das Grundkonzept hinter dem Tab-Activity
wie folgt
TabHost
ist ein Container für eine Tabbed-Fenster-Ansicht.
Diese Aufgabe hält zwei Kinder: eine Reihe von Registerkarte Etiketten, die der Benutzer auf bestimmte Registerkarte auszuwählen, und ein FrameLayout Objekt, das den Inhalt dieser Seite zeigt.
Das einzelne Element wird in der Regel unter Verwendung dieses Containerobjekt gesteuert, eher dann Werte für die untergeordneten Elemente selbst zu setzen.
TabWidget
zeigt eine Liste der Registerkarte Etiketten repräsentiert jede Seite in der Registerkarte Sammlung der Eltern. Das Container-Objekt für dieses Widget ist TabHost.
Wenn ein Benutzer eine Registerkarte auswählt, sendet das Objekt eine Nachricht an Container, TabHost, zu sagen, die Display-Seite zu wechseln. Der Behälter TabHost wird verwendet, Etiketten hinzuzufügen, die Callback-Handler hinzufügen und Rückrufe zu verwalten.
so anpassen, das Layout wie folgt -
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-3dip"
android:layout_weight="0" >
</TabWidget>
</LinearLayout>
</TabHost>
Androids Beispiele zur Rettung!
http://developer.android.com/resources/tutorials /views/hello-tabwidget.html
Just Swap tabcontent und Tabs in res / layout / main.xml:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Überprüfen Sie bitte den folgenden Link
Es gibt zwei Möglichkeiten Registerkarten am unteren Rand einer Registerkarte Aktivität angezeigt werden soll.
1) Unter Verwendung relativ Layout 2) Mit Layout_weight Attribute
http: //justkumar.blogspot. com / 2011/09 / Tabs-at-bottom-of-tabactivity-by.html
Überprüfen Sie dieses
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:id="@android:id/tabs">
</TabWidget>
</FrameLayout>
</LinearLayout>
Dies ist der Code für die unteren Registerkarte
<TabWidget
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:background="#0000"
android:id="@android:id/tabs"
/>
"android:layout_gravity="bottom"