Soru & Cevap

Fragment Sayfayı ScrollView içine alma ...

15.03.2016 - 04:09

Kod parçacığım aşağıdadır .

Bütün sayfayı ScrollView içine aldığımda hata alıyorum bunu nasıl sağlayabilirim .

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#d8d8d8"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_pager"
        android:layout_width="match_parent"
        android:layout_margin="5dp"
        android:layout_height="200dp">

        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:background="#fff"
            android:layout_margin="2dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_category"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_margin="5dp"
        android:layout_below="@id/card_view_pager"
        android:background="#000">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:background="#fff"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_randomProduct"
        android:layout_below="@id/card_view_category"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_randomProduct"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </android.support.v7.widget.CardView>


</RelativeLayout>

 

98 Görüntülenme

3 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-22128-1458633360.jpg
emrecelebiiii
18.03.2016 - 12:01

ScrollView kullandığında içine birden fazla component ekleyecekseniz eğer örneğin 2 tane textview 3 tane button gibi , bunu yapabilmek için hepsini 1 layout içine almalısınız.
<Scrollview>
        -<LinearLayout(yada RelativeLayout --- yani herhangi bir layoutta olabilir)>
                  -TextView />
                  -TextView />
                  -Button/>
        -</LinearLayout>
</ScrollView>
        

picture-64357-1469476477.jpg
bestekarx
15.03.2016 - 04:28

Yukarıdaki kodu şöyle değiştirdim :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#d8d8d8"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">



    <android.support.v7.widget.CardView
        android:id="@+id/card_view_pager"
        android:layout_width="match_parent"
        android:layout_margin="5dp"
        android:layout_height="200dp">

        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:background="#fff"
            android:layout_margin="2dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_category"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:layout_margin="5dp"
        android:layout_below="@id/card_view_pager"
        android:background="#000">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:background="#fff"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/card_view_randomProduct"
        android:layout_below="@id/card_view_category"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_randomProduct"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </android.support.v7.widget.CardView>

    </ScrollView>

</RelativeLayout>

RelativeLayoutun yerinede ScrollView eklemeyi denedim sonuç aynı aldığım hata :

Görsel kaldırıldı.
 

MainFragmenttaki 80. satır :

Görsel kaldırıldı.

Profile picture for user Gelecegi_Yazanlar_Ekibi
Gelecegi_Yazan…
15.03.2016 - 04:20

aldığınız hatayı gösterebilir misiniz?