如何在android中创建布局(请参阅附加图像)

问题描述:

我一直面临在布局下创建布局的问题。我该怎么做。我应该使用CustomView还是使用图像? 如果我使用CustomeView比我怎么做呢? 请建议任何自定义视图引用或想法来实现该布局。 我试图在自定义查看中使用onDraw方法中的Path比我真的不知道该怎么做,我被卡住了。 谢谢。如何在android中创建布局(请参阅附加图像)

enter image description here

+0

您可以使用卡的布局,并利用图像和按钮e.g查看,并做出哪些活动。 – Haroon

+0

使用FrameLayout .. –

添加卡片视图相关

compile 'com.android.support:cardview-v7:23.2.0' 

2.采取以下xml和把它放在你的桥接它。假设您使用RecyclerViewCardView:对于上面的布局使用两个ImageViewsButton或任何你想要的。设计图像并检查布局。您应该能够达到你想要 e.g

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_gravity="center" 
app:cardCornerRadius="2dp" 
app:cardElevation="1dp" 
app:cardUseCompatPadding="true" 
card_view:cardPreventCornerOverlap="false"> 
<RelativeLayout 
    android:id="@+id/ll1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/icons" 
    android:padding="@dimen/margin_small"> 

    <TextView 
     android:id="@+id/postTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginBottom="@dimen/margin_tiny" 
     android:maxLines="2" 
     android:text="TITLE OF THE POST" 
     android:textColor="@color/primary_text" 
     android:textSize="@dimen/font_regular" 
     android:textStyle="bold" 
     app:typeface="roboto_bold"/> 


    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="match_parent" 
     android:layout_height="160dp" 
     android:background="@color/icons" 
     android:focusable="false" 
     android:scaleType="centerCrop" 
     android:layout_below="@+id/postTitle" /> 

</RelativeLayout>