2016-04-26 68 views
-1

我一直面臨在佈局下創建佈局的問題。我該怎麼做。我應該使用CustomView還是使用圖像? 如果我使用CustomeView比我怎麼做呢? 請建議任何自定義視圖引用或想法來實現該佈局。 我試圖在自定義查看中使用onDraw方法中的Path比我真的不知道該怎麼做,我被卡住了。 謝謝。如何在android中創建佈局(請參閱附加圖像)

enter image description here

+0

您可以使用卡的佈局,並利用圖像和按鈕e.g查看,並做出哪些活動。 – Haroon

+0

使用FrameLayout .. –

回答

0

添加卡片視圖相關

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>