简体   繁体   中英

How to control height of card fragment in android wear?

I have an customized chart in card fragment which is a card showed on my LG G watch , I want to make it show in just one page without scrolling down.I tried to use LayoutParams and make it wrap content,but it does not work. ps: I'm using the GridViewPager widget.

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

How to make it looks like the what the 3rd pic shows.

Have you tried android:layout_width="match_parent" android:layout_height="match_parent"

Here is a sample app for GridViewPager in GitHub.

Its layout XML implemented as below:

<android.support.wearable.view.GridViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true" />

您可以使用Fragment而不是CardFragment,并在onCreateView()中设置自定义布局。

尝试将RelativeLayout用作视图的父级

我通过fragment.setExpansionEnabled(false);解决了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM