[英]different design for portrait and landscape mode in android
Hi i have created two fragments on single layout. 嗨,我已经在单一布局上创建了两个片段。
In layout-land : 在布局区域:
fragments need to display horizontally. 片段需要水平显示。
In layout-port : fragments need to display vertically. 在layout-port中:片段需要垂直显示。
Now i have to run the app on portrait mode means displaying the fragment vertically. 现在,我必须在纵向模式下运行该应用程序,这意味着垂直显示片段。 now i have to rotate these to landscape mode means displaying the fragments vertically only.
现在我必须将它们旋转到横向模式,这意味着只能垂直显示片段。
At the same time i have to run the app on landscape mode means displaying the fragment horizontally.now i have to rotate these to portrait mode means displaying the fragment horizontally. 同时我必须在横向模式下运行该应用程序意味着水平显示片段。现在我必须将它们旋转到纵向模式意味着水平显示片段。
But i wish to display the output like: 但我希望将输出显示为:
i have to run the app on portrait mode means displaying the fragment vertically. 我必须在纵向模式下运行该应用程序,这意味着垂直显示片段。 now i have to rotate these to landscape mode means displaying the fragments horizontally.
现在我必须将它们旋转到横向模式,这意味着水平显示碎片。
At the same time i have to run the app on landscape mode means displaying the fragment horizontally.now i have to rotate these to portrait mode means displaying the fragment vertically. 同时我必须在横向模式下运行该应用程序意味着水平显示片段。现在我必须将它们旋转到纵向模式意味着垂直显示片段。
How can i do ??? 我能怎么做 ???
Why am getting the result like above.please give me any suggestions . 为什么会得到上述结果。请给我任何建议。
EDIT: 编辑:
layout-land : fragment.xml: 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>
layout-port: fragment.xml: 布局端口: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>
This is my AndroidListFragmentActivity: 这是我的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.