我已经实现了新的BottomNavigationView(com.android.support:design:25.0.0),并且不知道如何设置选择索引或MenuItemid(在我的情况下,默认情况下应该选择mid item).我担心现在没有这种可能性,因为它太原始了,但无论如何任何帮助都将受到赞赏.谢谢!
android selectedindex android-design-library androiddesignsupport bottomnavigationview
我必须在我的应用程序中实现"标准"片段导航(请参阅链接).
问题是当设备处于纵向模式时,应该只显示1个片段,当它旋转到横向模式时,应显示2个片段.
我试着用两种不同的方式做到这一点:
1)我只使用一个具有不同肖像和横向布局的活动.
纵向布局xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/main_frame_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这里的景观布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<FrameLayout
android:id="@+id/main_frame_fragment_container_left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/main_frame_fragment_container_right"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Activity`s onCreate方法:
private static ItemsFragment mItemsFragment;
private static ItemDetailsFragment mItemDetailsFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (mItemsFragment == null) {
mItemsFragment = ItemsFragment.newInstance();
}
if (mItemDetailsFragment == null) {
mItemDetailsFragment = ItemDetailsFragment.newInstance();
}
if (isLandscape()) { …Run Code Online (Sandbox Code Playgroud) android screen-orientation android-fragments android-fragmentactivity onrestoreinstancestate
这里我有一个相当复杂的动画,可以使用 CoordinatorLayout 以简单的方式解决(我相信)。它有3个状态:
\n\n向下滚动内容应该会相应地导致视图以相反的方式出现。
\n\n\n\n我有一些使用 CoordinatorLayout 的经验,但我真的不确定我是否理解如何处理 2 个锚点。我了解滚动标志的工作原理以及缩放(第 2 页)和更改前景 alpha 的工作原理,我需要一个自定义行为实现,但现在我无法理解如何在复杂的情况下处理所有这些。
\n\n到目前为止我找到的只是Sa\xc3\xbal Molinero\ 的教程以及带有示例的教程。
\n\n因此,请为这里的糟糕描述感到抱歉,我当然会更新我的问题,并在我在这个问题上取得一些成功时添加源代码,但现在我很高兴得到一些提示或教程我\已经错过了。希望有人在项目中有类似的东西。
\n\n\nandroid android-animation android-coordinatorlayout android-collapsingtoolbarlayout android-nestedscrollview