Reputation: 177
I created a CardView (custom view) and uses it in a LinearLayout : 4 rows of 4 CardViews. i want each row to be the only one displayed on screen - and scroll between them.
When i use only LinearLayout (without ScrollView) - i see that the ViewCards first row is at the size of the screen - like i want. BUT - when i add the ScrollView it shrinks all 4 rows to the size of half of main screen. (i tried putting the ScrollView inside/above a new wrapping/inner LinearLayouts - all causes same wrong (for me) results)
THIS IS THE XML WITHOUT ScrollView :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.trytoget.ViewCard
android:id="@+id/viewCard1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.trytoget.ViewCard
android:id="@+id/viewCard5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard8"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.trytoget.ViewCard
android:id="@+id/viewCard9"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard10"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard11"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.trytoget.ViewCard
android:id="@+id/viewCard13"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard14"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard15"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
<com.example.trytoget.ViewCard
android:id="@+id/viewCard16"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
</com.example.trytoget.ViewCard>
</LinearLayout>
</LinearLayout>
where and how should i put my ScrollView?
my ViewCard.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/cardFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222222"
android:layout_margin="3dp"
>
<ImageView
android:id="@+id/cardBack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#111111"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:id="@+id/cardFront"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#111111"
android:src="@drawable/ic_launcher"
/>
</FrameLayout></LinearLayout>
Upvotes: 2
Views: 602