2015-09-10 44 views
-1

enter image description here使用卡片視圖進行設計?

你可以看到下面的圖像,我必須放置在第一卡片視圖partition.i罷工的圖像視圖中心知道該怎麼做,如果卡視圖有一個固定的大小,但在這種情況下,我應該換它根據屏幕size.what我還貼着below.i已經嘗試過很多方法,但在所有設備的確切位置並不像得到..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:padding="10dp"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="2" 
     card_view:cardCornerRadius="3dp" 
     card_view:cardElevation="1dp"> 

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

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="4"> 

       <ImageView 
        android:id="@+id/img_thumbnail" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scaleType="centerCrop" 
        android:src="@drawable/ic_profile_thumb" /> 

      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"> 

      </RelativeLayout> 

     </LinearLayout> 


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

    <View 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.1" /> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     card_view:cardCornerRadius="1dp" 
     card_view:cardElevation="1dp"> 

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

</LinearLayout> 

任何幫助將不勝感激..

對於參考...

enter image description here

回答

1

此佈局會產生所需的效果! (你必須自己投入利潤等)。

它採用CoordinatorLayout,你可以找到更多關於here

<?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" 
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 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 


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


      <ImageView 
       android:id="@+id/image" 
       android:layout_width="match_parent" 
       android:layout_height="192dp" 

       /> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="56dp" /> 
     </LinearLayout> 

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

    <android.support.v7.widget.CardView 

     android:id="@+id/card" 
     android:layout_width="match_parent" 
     android:layout_height="192dp"/> 

</LinearLayout> 


<View 
    android:layout_width="48dp" 
    android:layout_height="48dp" 
    android:background="@android:color/black" 
    android:layout_margin="16dp" 
    app:layout_anchor="@+id/image" 
    app:layout_anchorGravity="bottom|end" 

    /> 



<android.support.design.widget.FloatingActionButton 
    android:layout_width="48dp" 
    android:layout_height="48dp" 
    android:background="@android:color/black" 
    android:layout_margin="16dp" 
    app:layout_anchor="@+id/card" 
    app:layout_anchorGravity="bottom|end" 

    /> 

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

感謝的buddy..gud工作... –

+0

@ JoeyJubb請回答這個:http://stackoverflow.com/questions/36393540/no-shadow-elevation-underneath-second-card-if-there-are-two-card-in-the-layout –

1

這個怎麼樣...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:padding="10dp"> 

     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="2" 
      card_view:cardCornerRadius="3dp" 
      card_view:cardElevation="1dp"> 

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_marginBottom="50dp" 
        android:scaleType="centerCrop" 
        android:src="@drawable/ic_profile_thumb" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="50dp" 
        android:layout_gravity="bottom" 
        android:background="@color/red_primary_color"></LinearLayout> 

       <ImageView 
        android:layout_width="50dp" 
        android:layout_height="50dp" 
        android:layout_gravity="right|bottom" 
        android:layout_marginBottom="25dp" 
        android:layout_marginRight="20dp" 
        android:src="@drawable/abc_ic_menu_cut_mtrl_alpha" /> 


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


     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_marginTop="10dp" 
      android:layout_weight="1" 
      card_view:cardCornerRadius="1dp" 
      card_view:cardElevation="1dp"> 

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

    </LinearLayout>