2015-09-10 2 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-underne-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> 
Смежные вопросы