Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Wear:CardScrollView cannot scroll?

I use CardScrollView and CardFrame in my project, but the CardScrollView can not 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>
like image 210
Chaos Avatar asked Mar 14 '26 04:03

Chaos


1 Answers

CardScrollView does not seem to be made to working like ScrollView.

You can just wrap CardFrame with 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>
like image 91
user1436956 Avatar answered Mar 16 '26 16:03

user1436956



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!