【发布时间】:2015-05-05 02:44:26
【问题描述】:
我正在尝试在横向上呈现 DialogFragment,但我的基本 Activity 被锁定为纵向 (android:screenOrientation="portrait")。我通过在创建过程中进行对话来实现对话旋转。但是,当它显示时,容器似乎是旧格式(旋转前的宽度和高度)并且旋转的对话框不适合其中。此外,容器会剪切对话框的内容。
public class MenuFragment extends DialogFragment {
private final int mOrientation;
public PlantsMenuFragment(int orientation) {
mOrientation = orientation;
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View mRootView = inflater.inflate(R.layout.fragment_plants_menu,
container, false);
if (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE == mOrientation) {
mRootView.setRotation(90);
}
return mRootView;
}
}
我已经尝试在布局xml中设置它,但结果是一样的。 我如何解决它?或者有更好的方法以不同的活动方向呈现对话? 提前谢谢你,
【问题讨论】:
标签: android orientation dialogfragment