[Android-SDK-Japan:1015] 画面の向きでLayout切り替え

244 views
Skip to first unread message

サンドボックス@東原

unread,
Apr 24, 2010, 2:18:27 PM4/24/10
to Android-SDK-Japan
いつも大変お世話になっております。

ネット上の情報から縦画面、横画面にてLayoutを切り替えるにはlayout-landフォルダを作って横画面用に同じ名前のxmlファイルを入れ
ておけば、自動で切り替わると知りましたが、それだけではこちらの環境では横に傾けても縦のxmlが実行されます。
何か他に設定が必要なのでしょうか?xmlにも何か指定が必要でしょうか?

縦画面の場合は1ページを全画面で表示し、
横画面の場合は2ページを見開き表示させたいです。
またXperiaは画像のアスペクト比が全画面フルにすると合わないため余白のためダミーイメージを入れました。


■縦xml
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/dummyImage01"
android:layout_height="52px" android:layout_width="wrap_content"></
ImageView>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="480px"
android:layout_height="720px"
android:background="@drawable/p0"></ImageView>
<ImageView
android:id="@+id/dummyImage02"
android:layout_height="52px" android:layout_width="wrap_content"></
ImageView>
</LinearLayout>

■横xml(layout-landに入れたxmlファイル)
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/dummyImage01"
android:layout_width="92px"
android:layout_height="wrap_content"></ImageView>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="320px"
android:layout_height="480px"
android:background="@drawable/p2"></ImageView>
<ImageView
android:id="@+id/ImageView02"
android:layout_width="320px"
android:layout_height="480px"
android:background="@drawable/p3"></ImageView>
<ImageView
android:id="@+id/dummyImage02"
android:layout_width="92px"
android:layout_height="wrap_content"></ImageView>
</LinearLayout>

初歩的な質問で申し訳ありませんがよろしくお願いします。

--
このメールは Google グループのグループ「Android-SDK-Japan」の登録者に送られています。
このグループに投稿するには、android-...@googlegroups.com にメールを送信してください。
このグループから退会するには、android-sdk-ja...@googlegroups.com にメールを送信してください。
詳細については、http://groups.google.com/group/android-sdk-japan?hl=ja からこのグループにアクセスしてください。

サンドボックス@東原

unread,
Apr 28, 2010, 3:42:48 AM4/28/10
to Android-SDK-Japan
自己レスです。

上記、質問は当方の間違いが原因でした。
解決しましたので無視して下さい。

単純にマニフェストに
android:configChanges="orientation"
が入ってました。

調査せずに質問してしまい申し訳ありませんでした。
Reply all
Reply to author
Forward
0 new messages