[英]issues with coordinator layout in android ?
im using coordinator layout to achive this video VIDEO REQUIREMENT 我使用协调器布局来实现此视频的视频要求
NOW here is my layout : 现在这是我的布局:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tabanim_maincontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayoutProfileImageSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/relativeLayoutProfileImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/profileImage"
android:layout_width="110dip"
android:layout_height="110dip"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:layout_marginTop="@dimen/profile_image_margintop"
android:layout_marginLeft="@dimen/profile_image_marginleft"
android:background="@drawable/llayout_bk"
android:scaleType="centerCrop"/>
<LinearLayout
android:id="@+id/llayout_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/profile_rightside_layout_marginleft"
android:layout_toRightOf="@+id/profileImage"
android:orientation="vertical">
<TextView
android:id="@+id/textViewUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
android:layout_marginTop="@dimen/profile_username_margintop"
android:text="sdsdsd"
android:textColor="@android:color/black"
android:textSize="12sp"
android:singleLine="false"
android:textStyle="bold"/>
<ImageView
android:id="@+id/btn_follow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/follow_btn"
android:layout_marginTop="@dimen/profile_follow_margin_top"
/>
<TextView
android:id="@+id/textViewLocationProfileName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="sdsds"
android:textColor="@android:color/black"
android:textSize="15sp"
android:layout_marginBottom="3dp"
android:textStyle="normal" />
</LinearLayout>
<ImageView
android:id="@+id/img_editprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:padding="3dp"
android:layout_marginRight="@dimen/profile_edit_margin_right"
android:layout_marginTop="@dimen/profile_edit_margin_top"
android:background="@drawable/edit_btn"/>
</RelativeLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
/>
<View
android:id="@+id/view"
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@android:color/darker_gray"
android:layout_marginTop="@dimen/profile_tablayout_margintop"
/>
<com.ui.MyTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/MyCustomTabLayout"
/>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@android:color/darker_gray"
/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
but the issue im getting this type result 但问题是我得到这种类型的结果
it should show all items in a listview in vertical order while right now there are 5 items in listview but they are in limited length adn inside limited height i can see more items on scroll how to avoid ?
它应该以垂直顺序显示列表视图中的所有项目,而现在列表视图中有5个项目,但是它们的长度有限且内部高度有限,我可以在滚动条上看到更多的项目,如何避免?
To achieve a layout similar to the one posted in your demo video, which involves a collapsing toolbar, TabLayout
and ViewPager
I would recommend using the following gist as a guide: 为了实现与演示视频中发布的布局相似的布局,其中涉及折叠工具栏,
TabLayout
和ViewPager
我建议使用以下要点作为指导:
CollapsingToolbarLayout with TabLayout 使用TabLayout的CollapsingToolbarLayout
If you experience any issues with the fragments loaded into your ViewPager
not correctly wrapping content, then you can try the following: 如果加载到
ViewPager
的片段无法正确包装内容时遇到任何问题,则可以尝试以下操作:
anroid.support.v4.view.ViewPager
in your layout xml
. xml
anroid.support.v4.view.ViewPager
。 This custom ViewPager
will wrap child contents, and so is ideal for ListView
and RecyclerView
content. ViewPager
将包装子内容,因此非常适合ListView
和RecyclerView
内容。 ViewPager
to occupy any remaining space and not simply wrap content: Inside the Activity
class where you retrieve your AppBarLayout
and ViewPager
, and an AppBarLayout.OnOffsetChangedListener
to your AppBarLayout
, and use it to adjust the height of your ViewPager
so that its size adjusts to occupy the space below your AppBarLayout
: ViewPager
占据所有剩余空间而不是简单地包装内容:在Activity
类中,在其中检索AppBarLayout
和ViewPager
,以及AppBarLayout.OnOffsetChangedListener
到AppBarLayout
,并使用它来调整您的高度ViewPager
以便调整其大小以占据AppBarLayout
下面的空间: Activity
class: Activity
课:
//Class variable
private int windowHeight;
//...
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) {
if (windowHeight == 0) windowHeight = getWindow().getDecorView().getHeight();
int appBarHeight = (int) (appBarLayout.getHeight() + appBarLayout.getY());
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mViewPager.getLayoutParams();
params.height = (windowHeight - appBarHeight);
mViewPager.setLayoutParams(params);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.