2012-03-09 9 views
6

SDカードの存在によって2つのアクティビティが開きます。 1つのアクティビティには3つのButtonsTextViewがあり、もう1つはImageViewのボタンとズームコントロールです。方向を変えると、ボタンは水平方向にスクランブルされます。これを回避するには?オリエンテーションの変更中にXmlレイアウトが変更される

私の 'SD' カードレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#1E1E1E" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/button_print" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="44dp" 
     android:background="@drawable/my_button" 
     android:text="@string/print" /> 

    <TextView 
     android:id="@+id/text_SDmissing" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="80dp" 
     android:text="@string/SDmissing" 
     android:textSize="20dp" /> 

    <Button 
     android:id="@+id/button_camera" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/button_print" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="58dp" 
     android:background="@drawable/my_button" 
     android:text="@string/camera" /> 

    <Button 
     android:id="@+id/button_insert" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/text_SDmissing" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="40dp" 
     android:background="@drawable/my_button" 
     android:text="@string/insert" /> 

</RelativeLayout> 
+0

は私達にあなたのレイアウトxmlファイル(複数可)をご提示ください。 –

+1

plsあなたのxmlファイルを投稿してください。オリエンテーションに基づいてレイアウトを変更する必要がある場合は、レイアウトポートとレイアウトランドの2つのレイアウトを設定する必要があります。 – deepa

+1

ポートレート/ランドスケープのレイアウトを変えてみましたか? – Luksprog

答えて

8

あなたは、 "レイアウトランド" と呼ばれるプロジェクトでフォルダを作ることができます( "RES" ディレクトリ内)。ここでは、通常の「レイアウト」フォルダからすべてのXMLスタイルをコピーして、横向きモードでスタイルを変更することができます。 Androidはこれらのレイアウトを横向きモードで自動的に使用します。

あなたのプロジェクトは、次のようになります。

enter image description here

13

あなたは肖像画や風景モードのための個別のXMLファイルを作成し、別のディレクトリに配置する必要があります。デバイスは自動的に正しいものを選択します。あなたがチェックすることができ、さらに参考のために次のディレクトリ構造

res/layout/my_layout.xml 
res/layout-land/layout.xml 

を使用することができます。 http://developer.android.com/guide/practices/screens_support.html

+0

罰金:)私の別の質問は、レイアウトを使ってさまざまな画面サイズをサポートする方法です.....私がやっていることは、アプリを並べ替えて実行してデバイスをチェックするのですが、別のアプリでも同じことを実行してください..... – jxgn

+0

両方のファイル名は同じでなければなりません。 –

関連する問題