ページ

2011/09/23

Android ioschedのDashboardLayoutをタイトルなしのダイアログで使う

|
Google I/Oのアプリioschedに含まれているDashboardLayoutをカスタムダイアログで適用しようとしましたが、タイトルバーを非表示にしたところ、レイアウトが崩れてしまいました。
DashboardLayoutを使っているActivityのレイアウトファイルをそのまま使ったわけではなく、 Fragmentを使わないように書き換えたのですが、その際に誤って削ってしまった「android:layout_weight="1"」が原因でした。
以下、詳細のメモです。

まず、最初にダイアログに使ったレイアウトです。
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:minHeight="300dp"
    android:minWidth="300dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/background">
    <TextView
        android:text="@string/title_a"
        android:textColor="@color/accent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center" />
    <com.google.android.apps.iosched.ui.widget.DashboardLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1">
        <Button
            android:id="@+id/button_a"
            style="@style/DashboardButton"
            android:text="@string/label_button_a"
            android:drawableTop="@drawable/icon" />
        :
    </com.google.android.apps.iosched.ui.widget.DashboardLayout>
</LinearLayout>
これをタイトルバーありの状態で表示すると以下のようになります。