2017-04-24 82 views
2

我想得到这个结果。 Im trying to achieve this.但我得到的是This这个。下面是我尝试过的代码。我不知道我做错了什么。请帮忙。删除cardVie卡的背景顶部Android

<FrameLayout 
     android:id="@+id/bankToggle" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    <RadioGroup 
     android:layout_width="match_parent" 
     android:orientation="horizontal" 
     android:layout_height="52dp"> 
     <android.support.v7.widget.CardView 
      android:id="@+id/netbankingCard" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_marginBottom="-2dp" 
      style="@style/carViewQuickInvestRadio" 
      android:layout_marginRight="10dp" 
      android:layout_height="match_parent"> 
     <RelativeLayout 
      android:paddingTop="10dp" 
      android:paddingBottom="10dp" 
      android:id="@+id/netBankingrbrl" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <RelativeLayout 
      android:id="@+id/relContainRadThisMonth" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.AppCompatRadioButton 
       android:id="@+id/netbankingRB" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:checked="false" 
       app:buttonTint="@color/color_green" /> 

      <com.goalwise.customViews.CustomTextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="10dp" 
       android:textColor="@color/color_fab_text" 
       android:layout_toRightOf="@+id/netbankingRB" 
       android:text="@string/netbanking" 
       android:textSize="@dimen/dashboard_regular_text_size" 
       app:font="@string/gotham_font" /> 
     </RelativeLayout> 
      <LinearLayout 
       android:id="@+id/lnlContainRadThisMonth" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignBottom="@+id/relContainRadThisMonth" 
       android:layout_alignLeft="@+id/relContainRadThisMonth" 
       android:layout_alignRight="@+id/relContainRadThisMonth" 
       android:layout_alignTop="@+id/relContainRadThisMonth" 
       android:background="?android:selectableItemBackground" 
       android:orientation="horizontal"></LinearLayout> 

     </RelativeLayout> 
     </android.support.v7.widget.CardView> 
     <android.support.v7.widget.CardView 
      android:id="@+id/nachrbcard" 
      style="@style/carViewQuickInvestRadio" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_marginBottom="-2dp" 
      android:layout_height="match_parent"> 
     <RelativeLayout 
      android:paddingBottom="10dp" 
      android:paddingTop="10dp" 
      android:id="@+id/nachrbrl" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent"> 
     <RelativeLayout 
      android:id="@+id/relContainRadNach" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.AppCompatRadioButton 
       android:id="@+id/nachRB" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:checked="false" 
       app:buttonTint="@color/color_green" /> 

      <com.goalwise.customViews.CustomTextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="10dp" 
       android:textColor="@color/color_fab_text" 
       android:layout_toRightOf="@+id/nachRB" 
       android:text="@string/nach" 
       android:textSize="@dimen/dashboard_regular_text_size" 
       app:font="@string/gotham_font" /> 
     </RelativeLayout> 
      <LinearLayout 
       android:id="@+id/lnlContainRadNach" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignBottom="@+id/relContainRadNach" 
       android:layout_alignLeft="@+id/relContainRadNach" 
       android:layout_alignRight="@+id/relContainRadNach" 
       android:layout_alignTop="@+id/relContainRadNach" 
       android:background="?android:selectableItemBackground" 
       android:orientation="horizontal"></LinearLayout> 

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

     <FrameLayout 
      android:id="@+id/frame_toggle" 
      android:elevation="10dp" 
      android:layout_marginTop="42dp" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      > 
      <android.support.v7.widget.CardView 
       android:id="@+id/cardNbNach" 
       android:layout_marginTop="-1dp" 
       style="@style/carViewQuickInvestRadio.bg" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 
       <com.goalwise.customViews.CustomTextView 
        android:paddingBottom="15dp" 
        android:id="@+id/netBanking_both" 
        android:lineSpacingExtra="1.3dp" 
        android:paddingTop="12dp" 
        android:paddingLeft="15dp" 
        android:layout_gravity="top" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        style="@style/styleTextViewDisc" 
        android:text="@string/quick_net_both" 
        /> 
       <com.goalwise.customViews.CustomTextView 
        android:id="@+id/guarenteeTag" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="70dp" 
        android:text="@string/secure_transaction" 
        android:drawableLeft="@drawable/ic_lock" 
        android:gravity="center_horizontal" 
        android:drawablePadding="-20dp" 
        android:layout_gravity="bottom" 
        android:paddingTop="5dp" 
        android:paddingLeft="15dp" 
        android:paddingBottom="10dp" 
        style="@style/styleTextViewQuickDisc.noPadding" 

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


    </FrameLayout> 

上面的代码给了我显示的结果。我试图通过给-ve margin去除卡片视图顶部的边框。这无助于解决问题。请帮忙。

+0

在cardview card_view中使用此属性:cardElevation =“0dp” –

回答

2

This is how it looks!

你可以做这样的事情。这可能不是正确的方法。但它给你几乎相同的结果。

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v7.widget.CardView 
    android:id="@+id/radioOne" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_weight="1" 
    android:layout_toLeftOf="@+id/splitter" 
    app:cardBackgroundColor="@color/color_white" 
    app:cardCornerRadius="1dp" 
    app:cardElevation="4dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="50dp" 
    /> 

<View 
    android:id="@+id/splitter" 
    android:layout_width="1px" 
    android:layout_height="1px" 
    android:layout_marginTop="50dp" 
    android:layout_centerHorizontal="true"/> 

<android.support.v7.widget.CardView 
    android:id="@+id/radioTwo" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_toRightOf="@+id/splitter" 
    android:layout_weight="1" 
    app:cardBackgroundColor="#f7f7f7" 
    app:cardElevation="0dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="50dp" 
    /> 
<android.support.v7.widget.CardView 
    android:id="@+id/rootTwo" 
    android:layout_width="match_parent" 
    android:layout_height="100dp" 
    android:layout_below="@+id/radioOne" 
    app:cardBackgroundColor="@color/color_white" 
    app:cardCornerRadius="1dp" 
    app:cardElevation="4dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginBottom="8dp" 
    /> 
<android.support.v7.widget.CardView 
    android:id="@+id/patchView" 
    android:layout_width="match_parent" 
    android:layout_height="8dp" 
    android:layout_below="@+id/radioOne" 
    android:layout_toLeftOf="@+id/splitter" 
    app:cardBackgroundColor="@color/color_white" 
    app:cardCornerRadius="0dp" 
    app:cardElevation="4dp" 
    android:layout_marginTop="-4dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginBottom="8dp" 
    /> 

确保您所有的卡片视图在相同的父和它有相同的高度。当你给角落半径时,阴影变得可见。所以要隐藏那个影子,我正在应用一个补丁。你可以清楚地看到我是如何在XML中做到这一点的。

谢谢。

0
<android.support.v7.widget.CardView 
    android:id="@+id/cardNbNach" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 
      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 
     <LinearLayout 
      android:paddingTop="10dp" 
      android:layout_width="wrap_content" 
      android:paddingBottom="10dp" 
      android:id="@+id/relContainRadThisMonth" 
      android:orientation="horizontal" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.AppCompatRadioButton 
       android:id="@+id/netbankingRB" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:checked="false" 
       app:buttonTint="@color/grey" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="10dp" 
       android:textColor="#000000" 
       android:layout_toRightOf="@+id/netbankingRB" 
       android:text="Net Banking" 
       android:textSize="18sp" 
       /> 
     </LinearLayout> 
       <View 
        android:id="@+id/netbanking_bottomline" 
        android:layout_width="match_parent" 
        android:layout_height="2dp" 
        android:background="@color/grey" 
        /> 
      </LinearLayout> 
      <View 
       android:layout_width="2dp" 
       android:layout_height="match_parent" 
       android:background="@color/grey" 
       android:layout_marginRight="5dp"/> 
      <View 
       android:layout_width="2dp" 
       android:layout_height="match_parent" 
       android:background="@color/grey" 
       android:layout_marginLeft="5dp"/> 
      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:orientation="vertical"> 
     <LinearLayout 
      android:paddingBottom="10dp" 
      android:paddingTop="10dp" 
      android:id="@+id/relContainRadNach" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.AppCompatRadioButton 
       android:id="@+id/nachRB" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:checked="false" 
       app:buttonTint="@color/grey" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="10dp" 
       android:textColor="#000000" 
       android:layout_toRightOf="@+id/nachRB" 
       android:text="NACH" 
       android:textSize="18sp" 
       /> 
     </LinearLayout> 
       <View 
        android:id="@+id/nach_bottom_line" 
        android:layout_width="match_parent" 
        android:layout_height="2dp" 
        android:background="@color/grey" 
        /> 
      </LinearLayout> 
     </LinearLayout> 
    <TextView 
     android:paddingBottom="15dp" 
     android:id="@+id/netBanking_both" 
     android:lineSpacingExtra="1.3dp" 
     android:paddingTop="12dp" 
     android:paddingLeft="15dp" 
     android:layout_gravity="top" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="test" 
     /> 
    <TextView 
     android:id="@+id/guarenteeTag" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="70dp" 
     android:text="test" 
     android:gravity="center_horizontal" 
     android:drawablePadding="-20dp" 
     android:layout_gravity="bottom" 
     android:paddingTop="5dp" 
     android:paddingLeft="15dp" 
     android:paddingBottom="10dp" 


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

您可以简单地使用单卡时,点击NetBanking时,你需要去的视图(netbanking_bottomline)的知名度,当点击NACH,你需要去的视图(nach_bottom_line)。

这可能是一个简单的步骤来隐藏点击项目的底线,而不是为卡片设置负边距。

+0

但影子的东西不会正确 –

+0

是的..但它会类似于影子.. – Darsy