私は Android が初めてで、オンラインで見つけたコードから FragmentActivity を使用してタブを作成しようとしました。 http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
これは私の FragmentActivity http://pastie.org/pastes/5170802/text?key=jhowuevxe2fshlwu5tisgです
画像とテキストを使用したカスタム レイアウトを使用したいと考えています。
//tab_indicator.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dip"
android:layout_height="55dip"
android:layout_weight="1"
android:orientation="vertical"
android:background="@drawable/tab_indicator"
android:padding="5dp">
<ImageView android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/icon"/>
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
style="?android:attr/tabWidgetStyle"/>
</RelativeLayout>
ここで同様の質問を見つけました: FragmentActivity でカスタム タブを作成しますが、コードにソリューションを適用する方法がわかりませんでした。誰か教えてくれませんか?ありがとうございました。
アップデート:
コードでカスタム レイアウトを拡張することができました。しかし、私は別のエラーに直面しました。これは私の最新のコードhttp://pastie.org/pastes/5187362/text?key=74r87diquysvruwsam1tqを AdilSoomro http://adilsoomro.blogspot.com/2011/06/iphone-like-tabs-in-から FragmentActivity に微調整したものですandroid.htmlコード (TabActivity を使用) からの参照を含む
- http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
- http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
私の最新のコードは、そのレイアウト(tab_indicator.xml)にhttp://pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmwを設定して、このようにレイアウトを正常に膨らませます
しかし、タブを下に揃える必要があります。下に揃えると、コード layout_gravity="bottom" はグラフィカル レイアウトで機能しましたが、実行すると、相対レイアウトの背景が画面全体を埋め尽くします。コードhttp://pastie.org/pastes/5187445 /text?key=6dz2tsiggey9se51d2thtq
誰かが私が間違ったことを教えてもらえますか?