8

Tôi có nút tác vụ nổi mà tôi muốn thêm trên đầu trang của chế độ xem cuộn để nút vẫn ở, ngay cả khi bạn cuộn. Tôi muốn nó ở trên cùng của scrollview và ở góc dưới bên phải của màn hình. Tôi cần sử dụng kết hợp các chế độ xem nào để thực hiện điều này?Cách thêm nút hành động nổi ở trên cùng của scrollview

Dưới đây là file xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.nhscoding.safe2tell.STORIES" 
    android:background="@color/stor_back"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="bottom" 
     > 

     <com.getbase.floatingactionbutton.FloatingActionButton 
      android:id="@+id/pink_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      fab:fab_icon="@drawable/ic_add" 
      fab:fab_colorNormal="@color/fab_back" 
      fab:fab_colorPressed="@color/fab_pressed_back" 
      android:layout_gravity="end" 
      android:layout_marginBottom="16dp" 
      android:layout_marginRight="16dp"/> 
     </LinearLayout> 


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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 



      <android.support.v7.widget.CardView 
       xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       > 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card1_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title1" 
        /> 


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

      <android.support.v7.widget.CardView 
       xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view2" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view1"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card2_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        /> 

       <TextView 
        android:id="@+id/info_text2" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"/> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view3" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view2"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card3_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        /> 

       <TextView 
        android:id="@+id/info_text3" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent"/> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView 
       xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card4_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title4" 
        /> 


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

      <android.support.v7.widget.CardView 
       xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="16dp" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card5_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title5" 
        /> 


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


      </LinearLayout> 
     </ScrollView> 




</RelativeLayout> 
+0

Di chuyển FAB của bạn theo sau 'ScrollView' trong XML. Những đứa trẻ sau đó trong một 'RelativeLayout' trôi nổi trên những đứa trẻ trước đó trên trục Z, mặc dù các công cụ nâng cao của Android 5.0 cũng phát ở đây. – CommonsWare

+0

Cảm ơn! Điều đó đã làm việc @CommonsWare – user3566841

Trả lời

11

Sau trẻ em trong một RelativeLayout có xu hướng nổi trên trẻ em trước đó trong một RelativeLayout.

(tôi nói "có xu hướng" vì Android 5.0 của elevation thứ cũng đóng một vai trò và mối quan hệ giữa họ là mập mờ)

Vì vậy, để có một phao FAB hơn một ScrollView trong một RelativeLayout , đảm bảo rằng ScrollView được xác định đầu tiên trong XML, với FAB sau nó. Điều này sẽ không ảnh hưởng đến các quy tắc X/Y, nhưng nó sẽ có FAB xuất hiện trên ScrollView trên trục Z.

Một khả năng khác, nếu bạn chỉ hỗ trợ Android 5.0+, sẽ tự sử dụng android:elevation để tăng FAB.

+0

Xin chào @CommonsWare Hãy giúp tôi trong Câu hỏi của tôi vì tôi đã làm việc trên đó nhưng không thể thực hiện Bố cục i được cung cấp trong hình ảnh như sau: http://stackoverflow.com/questions/31238880/create-the- layout-with-cardview-and-floating-action-button-android –

+0

Người đàn ông giàu có .... – Tarun

+0

hoạt động tốt nhờ –

9

thử điều này:

android: layout_alignParentRight = "true"

android: layout_alignParentBottom = "true"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.nhscoding.safe2tell.STORIES" 
    android:background="@color/stor_back"> 


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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 


      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card1_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title1" /> 


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

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view2" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view1"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card2_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" /> 

       <TextView 
        android:id="@+id/info_text2" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view3" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view2"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card3_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" /> 

       <TextView 
        android:id="@+id/info_text3" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card4_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title4" /> 


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

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="16dp" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card5_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title5" /> 


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


     </LinearLayout> 
    </ScrollView> 

     <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true" 
     android:layout_margin="10dp"> 

     <com.getbase.floatingactionbutton.FloatingActionButton 
      android:id="@+id/pink_icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      fab:fab_icon="@drawable/ic_add" 
      fab:fab_colorNormal="@color/fab_back" 
      fab:fab_colorPressed="@color/fab_pressed_back" 
      android:layout_gravity="end" 
      android:layout_marginBottom="16dp" 
      android:layout_marginRight="16dp" /> 
    </LinearLayout> 

</RelativeLayout> 
0

Bạn có thể sử dụng android.support.design.widget.CoordinatorLayout làm bố cục gốc. Tạo hai xml mà bạn có thể đặt thanh cuộn hoặc danh sách. Khác là vùng chứa chính chứa toàn bộ thông tin với số FloatingActionButton của bạn.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

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

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     app:elevation="6dp" 
     app:backgroundTint="@color/colorAccent" 
     app:pressedTranslationZ="12dp" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/ic_add" /> 

</android.support.design.widget.CoordinatorLayout> 

content_main.xml

Ở đây bạn có thể đặt ScrollBar của bạn. Nó khá dễ dàng.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" 
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:gravity="center" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_main" 
    tools:context=".MainActivity"> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 


      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card1_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title1" /> 


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

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view2" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view1"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card2_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" /> 

       <TextView 
        android:id="@+id/info_text2" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view3" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius" 
       android:layout_below="@id/card_view2"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card3_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" /> 

       <TextView 
        android:id="@+id/info_text3" 
        android:layout_marginTop="16dp" 
        android:layout_marginBottom="0dp" 
        android:layout_marginLeft="16dp" 
        android:layout_marginRight="16dp" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" /> 
      </android.support.v7.widget.CardView> 

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="@dimen/card_margin_bottom" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card4_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title4" /> 


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

      <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/card_view1" 
       android:layout_width="match_parent" 
       android:layout_height="200dp" 
       android:layout_marginTop="@dimen/card_margin_top" 
       android:layout_marginBottom="16dp" 
       android:layout_marginLeft="@dimen/card_margin_left" 
       android:layout_marginRight="@dimen/card_margin_right" 
       card_view:cardCornerRadius="@dimen/card_radius"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="@dimen/card_title_top" 
        android:layout_marginBottom="@dimen/card_title_bottom" 
        android:layout_marginLeft="@dimen/card_title_left" 
        android:layout_marginRight="@dimen/card_title_right" 
        android:text="@string/card5_title" 
        android:textSize="@dimen/card_title_size" 
        android:gravity="top" 
        android:id="@+id/title5" /> 


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


     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
Các vấn đề liên quan