gpt4 book ai didi

android - Viewstub上面有一个viewpager()

转载 作者:行者123 更新时间:2023-11-29 00:21:43 25 4
gpt4 key购买 nike

我有一个包含 4 个 SherlockFragment 的 viewpager(带有 actionbar sherlock),它们都在 SherlockFragmentActivity 中。

每个选项卡都有自己的 backStack(我可以在每个 SherlockFragment 上堆叠多个 fragment )

我想做的是当我在列表中选择一个项目时,我想让一个ViewStub(它是一个播放器)可见

我的问题是 ViewPager 不重新调整自身。播放器变得可见,但在 viewpager 后面。

这是主要的 SherlockFragmentActivity:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/ActivityDark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".ActivityMain" >

<ViewStub
android:id="@+id/main_stubplayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:inflatedId="@+id/fragment_allzic_player"
android:layout="@layout/view_player" />

<android.support.v4.view.ViewPager
android:id="@+id/main_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/main_stubplayer" >
</android.support.v4.view.ViewPager>

</RelativeLayout>

这是ViewStub:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/banner_player_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/cell_height"
android:background="@color/clr_player"
android:clickable="true" >

[...the content does not matter the height is fixe]
</RelativeLayout>

以下是我如何使它可见:

public void showPlayerBanner(String title) {
if (mViewPlayer == null) {
ViewStub stub = (ViewStub) findViewById(R.id.main_stubplayer);
mViewPlayer = stub.inflate();
} else {
mViewPlayer.setVisibility(View.VISIBLE);
}
}

最佳答案

尝试 LinearLayout vertical 而不是 RelativeLayout 并将最小/最大高度设置为 viewstub。

要了解更多关于布局差异的信息,文章是here

关于android - Viewstub上面有一个viewpager(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22563550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com