且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何实现一个固定的左窗格中的Andr​​oid平板电脑的布局?

更新时间:2023-11-16 11:53:28

  

它采用了分离视图控制器为片剂,其在Android的行话同时,您可以present两项活动相映成趣。

没有。在Android的行话,你不能present两项活动并排同时。您的可以的present两个片段并列同时进行。

  

你会如何建议在Android中实现这一点?

使用的片段。使用 FragmentTransaction 来代替右手片段需要根据用户的输入。你的整体活动布局可以有一个水平的LinearLayout (用的android:layout_weight 控制尺寸为左,右两侧),用<片断> 元素的左侧和的FrameLayout 的权利

  

我应该使用一个单一的活动,并手动执行片段之间的转换在右侧面板中?

是的,要达到你的要求。

I'm porting an iPhone+iPad app to Android. It uses a Split View Controller for tablets which in Android lingo allows you to present two Activities side by side simultaneously (Edit: Android only allows one Activity on screen as mentioned by @commonsware below. The next best thing is to use fragments, but the Action Bar can only exist at the Activity level, meaning it will have to expand the entire width of the screen. It wonder if a Split Activity Controller will be coming to the Android Platform.)

The tablet landscape layout has a fixed left pane for statistics that never changes. The right hand pane functions just like the phone version of the app. Transitions occur exclusively on the right hand pane. i.e. the whole screen doesn't slide when changing activities, only the right pane. How would you recommend implementing this in Android?

Should I use a single activity and manually perform transitions between fragments in the right panel? This app has 25 screens and will have an alternate layout for phones, so I'm trying to plan ahead and do this right the first time :) Thanks for your help!

It uses a Split View Controller for tablets which in Android lingo allows you to present two Activities side by side simultaneously.

No. In "Android lingo", you cannot "present two Activities side by side simultaneously". You can present two fragments side by side simultaneously.

How would you recommend implementing this in Android?

Use fragments. Use a FragmentTransaction to replace the right-hand fragment as needed based on user input. Your overall activity layout could have a horizontal LinearLayout (with android:layout_weight to control the sizes for the left and right sides), with a <fragment> element for the left and a FrameLayout for the right.

Should I use a single activity and manually perform transitions between fragments in the right panel?

Yes, to achieve what you ask for.