Android Wear: CardScrollView can't scroll?

I am using CardScrollView and CardFrame in my project, but CardScrollView cannot scroll, here is my code, any suggestion?

CardScrollViewActivity.java

public class CardScrollViewActivity extends Activity {

    private CardFrame cardFrame;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.card_scroll_view);
        cardFrame=(CardFrame)findViewById(R.id.card_frame);
        cardFrame.setExpansionDirection(CardFrame.EXPAND_UP);
        cardFrame.setExpansionEnabled(true);
        cardFrame.setExpansionFactor(CardFrame.NO_EXPANSION);
    }
}

      

card_scroll_view.xml

<android.support.wearable.view.CardScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.wearable.view.CardFrame
        android:id="@+id/card_frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="TestTextView\nTestTextView\nTestTextView\nTestTextView\nTestTextView\nTestTextView\nTestTextView\nTestTextView"/>
    </android.support.wearable.view.CardFrame>
</android.support.wearable.view.CardScrollView>

      

+3


source to share


1 answer


CardScrollView doesn't seem to work like ScrollView.

You can just wrap the CardFrame with a ScrollView.



<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <android.support.wearable.view.CardFrame
            android:id="@+id/cardFrame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </android.support.wearable.view.CardFrame>

    </FrameLayout>

</ScrollView>

      

+5


source







All Articles