0

私はCardViewを使ってレイアウトを作成しました。カードビューのリストを表示していますが、スクロールしていないものは私のレイアウトをご覧ください。私もAppWall.javaを作成しました。それを動作させるには、Javaクラスやレイアウトに何かを追加する必要があります。私のアプリでCardViewのリストがスクロールしていません

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:gravity="center_horizontal" 
    android:orientation="vertical" 
    tools:context="net.example.app.AppWall"> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#ddd" 
     android:orientation="vertical" 
     android:padding="16dp"> 


     <Space 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/toolbar" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:minHeight="55dp" 
      android:id="@+id/topspace"> 
     </Space> 



     <android.support.v7.widget.CardView 
      android:id="@+id/android_card_view_example" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 


      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#fff" 
       android:elevation="4dp" 
       android:padding="16dp"> 



       <ImageView 
        android:id="@+id/cardview_image" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="18dp" 
        android:src="@drawable/profile" /> 

       <TextView 
        android:id="@+id/cardview_list_title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/cardview_image" 
        android:paddingBottom="5dp" 
        android:text="Flipkart App" 
        android:textSize="24sp" /> 

       <TextView 
        android:id="@+id/tvInstall" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/cardview_list_title" 
        android:layout_toRightOf="@+id/cardview_image" 
        android:text="Install" 
        android:textColor="@android:color/holo_green_dark" 
        android:textSize="16sp" /> 

      </RelativeLayout> 

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

     <android.support.v7.widget.CardView 
      android:id="@+id/android_card_view_example1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#fff" 
       android:elevation="4dp" 
       android:padding="16dp"> 

       <ImageView 
        android:id="@+id/cardview_image1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="18dp" 
        android:src="@drawable/profile" /> 

       <TextView 
        android:id="@+id/cardview_list_title1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/cardview_image1" 
        android:paddingBottom="5dp" 
        android:text="Viral Android" 
        android:textSize="24sp" /> 

       <TextView 
        android:id="@+id/short_description1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/cardview_list_title1" 
        android:layout_toRightOf="@+id/cardview_image1" 
        android:text="Free android tutorials and examples for beginners and expert." 
        android:textColor="#8b8b8b" /> 

      </RelativeLayout> 

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

     <android.support.v7.widget.CardView 
      android:id="@+id/android_card_view_example2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#fff" 
       android:elevation="4dp" 
       android:padding="16dp"> 

       <ImageView 
        android:id="@+id/cardview_image2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="18dp" 
        android:src="@drawable/profile" /> 

       <TextView 
        android:id="@+id/cardview_list_title2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/cardview_image2" 
        android:paddingBottom="5dp" 
        android:text="Viral Android" 
        android:textSize="24sp" /> 

       <TextView 
        android:id="@+id/short_description2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/cardview_list_title2" 
        android:layout_toRightOf="@+id/cardview_image2" 
        android:text="Free android tutorials and examples for beginners and expert." 
        android:textColor="#8b8b8b" /> 

      </RelativeLayout> 

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

     <android.support.v7.widget.CardView 
      android:id="@+id/android_card_view_example3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#fff" 
       android:elevation="4dp" 
       android:padding="16dp"> 

       <ImageView 
        android:id="@+id/cardview_image3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="18dp" 
        android:src="@drawable/profile" /> 

       <TextView 
        android:id="@+id/cardview_list_title3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/cardview_image3" 
        android:paddingBottom="5dp" 
        android:text="Viral Android" 
        android:textSize="24sp" /> 

       <TextView 
        android:id="@+id/short_description3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/cardview_list_title3" 
        android:layout_toRightOf="@+id/cardview_image3" 
        android:text="Free android tutorials and examples for beginners and expert." 
        android:textColor="#8b8b8b" /> 

      </RelativeLayout> 

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

     <android.support.v7.widget.CardView 
      android:id="@+id/android_card_view_example4" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_marginTop="16dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#fff" 
       android:elevation="4dp" 
       android:padding="16dp"> 

       <ImageView 
        android:id="@+id/cardview_image4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="18dp" 
        android:src="@drawable/profile" /> 

       <TextView 
        android:id="@+id/cardview_list_title4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/cardview_image4" 
        android:paddingBottom="5dp" 
        android:text="Viral Android" 
        android:textSize="24sp" /> 

       <TextView 
        android:id="@+id/short_description4" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/cardview_list_title4" 
        android:layout_toRightOf="@+id/cardview_image4" 
        android:text="Free android tutorials and examples for beginners and expert." 
        android:textColor="#8b8b8b" /> 

      </RelativeLayout> 

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

    </LinearLayout> 

    <include layout="@layout/toolbar" /> 

</RelativeLayout> 
+0

なぜ負の投票を持たなければならないことをウル相対レイアウト

<RelativeLayout> <Scrollview> <LinearLayout> <Cardview> <Cardview> </LinearLayout> </ScrollView> </RelativeLayout> 

尊重の内部で意見の残りの親である必要があります。あなたは愚か者や馬鹿は否定的な投票だけをコメントすることができます。 –

答えて

1

ScrollViewは、RelativeLayoutの後で線形レイアウトの前に使用します。 CardViewは、スクロール可能な機能を含まない単純なビューです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:tools="http://schemas.android.com/tools" 
android:gravity="center_horizontal" 
android:orientation="vertical" 
tools:context="net.example.app.AppWall"> 
<ScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ddd" 
    android:orientation="vertical" 
    android:padding="16dp"> 


    <Space 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/toolbar" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:minHeight="55dp" 
     android:id="@+id/topspace"> 
    </Space> 



    <android.support.v7.widget.CardView 
     android:id="@+id/android_card_view_example" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 


     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#fff" 
      android:elevation="4dp" 
      android:padding="16dp"> 



      <ImageView 
       android:id="@+id/cardview_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="18dp" 
       android:src="@drawable/profile" /> 

      <TextView 
       android:id="@+id/cardview_list_title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/cardview_image" 
       android:paddingBottom="5dp" 
       android:text="Flipkart App" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/tvInstall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/cardview_list_title" 
       android:layout_toRightOf="@+id/cardview_image" 
       android:text="Install" 
       android:textColor="@android:color/holo_green_dark" 
       android:textSize="16sp" /> 

     </RelativeLayout> 

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

    <android.support.v7.widget.CardView 
     android:id="@+id/android_card_view_example1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#fff" 
      android:elevation="4dp" 
      android:padding="16dp"> 

      <ImageView 
       android:id="@+id/cardview_image1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="18dp" 
       android:src="@drawable/profile" /> 

      <TextView 
       android:id="@+id/cardview_list_title1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/cardview_image1" 
       android:paddingBottom="5dp" 
       android:text="Viral Android" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/short_description1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/cardview_list_title1" 
       android:layout_toRightOf="@+id/cardview_image1" 
       android:text="Free android tutorials and examples for beginners and expert." 
       android:textColor="#8b8b8b" /> 

     </RelativeLayout> 

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

    <android.support.v7.widget.CardView 
     android:id="@+id/android_card_view_example2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#fff" 
      android:elevation="4dp" 
      android:padding="16dp"> 

      <ImageView 
       android:id="@+id/cardview_image2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="18dp" 
       android:src="@drawable/profile" /> 

      <TextView 
       android:id="@+id/cardview_list_title2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/cardview_image2" 
       android:paddingBottom="5dp" 
       android:text="Viral Android" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/short_description2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/cardview_list_title2" 
       android:layout_toRightOf="@+id/cardview_image2" 
       android:text="Free android tutorials and examples for beginners and expert." 
       android:textColor="#8b8b8b" /> 

     </RelativeLayout> 

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

    <android.support.v7.widget.CardView 
     android:id="@+id/android_card_view_example3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#fff" 
      android:elevation="4dp" 
      android:padding="16dp"> 

      <ImageView 
       android:id="@+id/cardview_image3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="18dp" 
       android:src="@drawable/profile" /> 

      <TextView 
       android:id="@+id/cardview_list_title3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/cardview_image3" 
       android:paddingBottom="5dp" 
       android:text="Viral Android" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/short_description3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/cardview_list_title3" 
       android:layout_toRightOf="@+id/cardview_image3" 
       android:text="Free android tutorials and examples for beginners and expert." 
       android:textColor="#8b8b8b" /> 

     </RelativeLayout> 

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

    <android.support.v7.widget.CardView 
     android:id="@+id/android_card_view_example4" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="16dp"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#fff" 
      android:elevation="4dp" 
      android:padding="16dp"> 

      <ImageView 
       android:id="@+id/cardview_image4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="18dp" 
       android:src="@drawable/profile" /> 

      <TextView 
       android:id="@+id/cardview_list_title4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_toRightOf="@+id/cardview_image4" 
       android:paddingBottom="5dp" 
       android:text="Viral Android" 
       android:textSize="24sp" /> 

      <TextView 
       android:id="@+id/short_description4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/cardview_list_title4" 
       android:layout_toRightOf="@+id/cardview_image4" 
       android:text="Free android tutorials and examples for beginners and expert." 
       android:textColor="#8b8b8b" /> 

     </RelativeLayout> 

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

    </LinearLayout> 
    </ScrollView> 

    <include layout="@layout/toolbar" /> 

     </RelativeLayout> 

その他のことカードのリストを表示するにはRecyclerViewを使用します。

+0

それを追加することができません私のコードを参照してください私はアンドロイドスタジオでは、エラーを取得するスクロールバーを追加することはできません。私は何かを逃した –

+0

その仕事。なぜ私にスクロールビューを挿入させないのか –

2

ScrollviewはscrollViewが唯一の直接の子

関連する問題