簡體   English   中英

Android中縱向和橫向模式的不同設計

[英]different design for portrait and landscape mode in android

嗨,我已經在單一布局上創建了兩個片段。

在布局區域:

片段需要水平顯示。

在layout-port中:片段需要垂直顯示。

現在,我必須在縱向模式下運行該應用程序,這意味着垂直顯示片段。 現在我必須將它們旋轉到橫向模式,這意味着只能垂直顯示片段。

同時我必須在橫向模式下運行該應用程序意味着水平顯示片段。現在我必須將它們旋轉到縱向模式意味着水平顯示片段。

但我希望將輸出顯示為:

我必須在縱向模式下運行該應用程序,這意味着垂直顯示片段。 現在我必須將它們旋轉到橫向模式,這意味着水平顯示碎片。

同時我必須在橫向模式下運行該應用程序意味着水平顯示片段。現在我必須將它們旋轉到縱向模式意味着垂直顯示片段。

我能怎么做 ???

為什么會得到上述結果。請給我任何建議。

編輯:

layout-land:fragment.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/_listDetails"

>
   <ImageView
        android:id="@+id/refresh"
        android:layout_width="wrap_content"
        android:layout_height="45dp"

        android:layout_gravity="center_vertical"
        android:layout_toLeftOf="@+id/pos"
        android:src="@drawable/ref_off" />
<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/layout"
android:background="#414042"
android:orientation="horizontal" >

<fragment
  android:id="@+id/activity_main"
  android:name="com.notch.notchbolly.MainActivity"
  android:layout_width="0px"
  android:layout_height="match_parent"
  android:layout_weight="0.83"

  />
  <View
    android:layout_width="2dp"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    />
 <fragment
  android:id="@+id/subcate"
  android:name="com.notch.notchbolly.SubCate"
  android:layout_width="0px"
  android:layout_height="match_parent"
  android:layout_weight="1" />
  </LinearLayout>
  </RelativeLayout>

布局端口:fragment.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/_listDetails"

 >
  <ImageView
         android:id="@+id/refresh"
        android:layout_width="wrap_content"
        android:layout_height="45dp"

        android:layout_gravity="center_vertical"
        android:layout_toLeftOf="@+id/pos"
        android:src="@drawable/ref_off" />
<LinearLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/layout"
android:background="#414042"
android:id="@+id/orien"
android:orientation="vertical"
 >

<fragment
  android:id="@+id/activity_main"
  android:name="com.notch.notchbolly.MainActivity"
  android:layout_width="fill_parent"
  android:layout_height="200dp"

  />
 <View
    android:layout_width="fill_parent"
    android:layout_height="3dp"
    android:background="#FF0000"
    />
<fragment
  android:id="@+id/subcate"
  android:name="com.notch.notchbolly.SubCate"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  />


   </LinearLayout>
   </RelativeLayout>

這是我的AndroidListFragmentActivity:

    public  class AndroidListFragmentActivity extends FragmentActivity  {


       /** Called when the activity is first created. */
    @Override
      public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment);

    ImageView refresh = (ImageView) findViewById(R.id.refresh);
        refresh.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {

                Intent in = new Intent(AndroidListFragmentActivity.this, AndroidListFragmentActivity.class);
                startActivity(in);
                } 
            }); 



                }
            @Override
            public void onConfigurationChanged ( Configuration newConfig )
              {
              super.onConfigurationChanged(newConfig);

        }

        }

從清單文件中的活動聲明中刪除android:configChanges="orientation"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM