-2

Мне интересно, как реализовать макет карты, как в учебнике Google, в учебнике есть только простой вид карты, но как получить такой результат? https://developer.android.com/design/material/images/card_travel.pngКак реализовать Google Like Card View

Я могу реализовать это, но мне нужно сделать это эффективно, чтобы увеличить иерархию представлений, делая рендеринг длинным.

Просьба привести любой пример, как я могу достичь такого вида.

ответ

2

enter image description here

Просто добавьте это в зависимости:

compile 'com.android.support:cardview-v7:21.+' 

Пример использования в макете:

<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="8dp" 
    card_view:cardCornerRadius="1dp"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:context="com.eugene.fithealth.TestingForSO"> 


     <ImageView 
      android:id="@+id/image" 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:orientation="vertical" 
      android:scaleType="centerCrop" 
      android:src="@drawable/drawer_image"/> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_above="@+id/description" 
      android:background="#50000000" 
      android:gravity="center_vertical" 
      android:paddingLeft="16dp" 
      android:text="Hello World!" 
      android:textColor="#fff" 
      android:textSize="22dp"/> 


     <TextView 
      android:id="@+id/description" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/image" 
      android:layout_marginBottom="8dp" 
      android:paddingLeft="16dp" 
      android:paddingTop="16dp" 
      android:text="Random Text Blah Blah Blah" 
      android:textSize="16dp"/> 

     <Button 
      android:id="@+id/btnOne" 
      style="?android:buttonBarButtonStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/description" 
      android:layout_marginBottom="4dp" 
      android:layout_marginLeft="4dp" 
      android:text="Button One" 
      android:textColor="#000"/> 

     <Button 
      android:id="@+id/btnTwo" 
      style="?android:buttonBarButtonStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/description" 
      android:layout_toRightOf="@id/btnOne" 
      android:text="Button Two" 
      android:textColor="#03A9F4"/> 

    </RelativeLayout> 
</android.support.v7.widget.CardView> 
+0

Как сделать точно такой же вид? – dyoordec

+0

@dyoordec только что обновил мой ответ. Если это то, что вы ищете, и решает ваш вопрос, не забудьте отметить его как правильное. –

+0

@dyoordec Верно ли это? –

1

Попробуйте эту cardlib библиотеку. Я использую его, и это здорово!