2017-07-02 131 views
2

第一张图片是我的结果,我想让它看起来像第二张。我试图让角落半径,但它没有出现在屏幕上。我不知道什么是问题,并且海拔不会出现在父卡片视图中。如何为一些小孩成员设置cardview的拐角半径?

提前谢谢。

enter image description here

enter image description here

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ffffff" 
    tools:context="com.software_solutions.optimus_tech_project201709.CourseSelect.CourseSelectionActivity"> 

    <Button 
     android:id="@+id/register" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:text="Register" /> 


    <Button 
     android:id="@+id/you" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:text="you" /> 

    <ImageView 
     android:id="@+id/dialogImageView" 
     android:layout_width="match_parent" 
     android:layout_height="220dp" 
     android:scaleType="fitXY" 
     android:src="@drawable/dialog" 
     android:text="Hello" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/dialogImageView" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="-180dp" 
     android:gravity="center" 
     android:orientation="vertical"> 

     <ImageView 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:src="@drawable/select_course" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dp" 
      android:text="SELECT A COURSE" 
      android:textColor="#ffffff" 
      android:textSize="25dp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="OK" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/dialogImageView" 
     android:orientation="vertical" 
     android:weightSum="2"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerViewSelectCourse" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:padding="5dp" /> 


     <android.support.v7.widget.CardView 
      android:id="@+id/cardViewDemo1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="10dp" 
      android:layout_weight="1" 
      android:elevation="3dp" 
      app:cardCornerRadius="10dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#e4a455" 
       android:orientation="vertical" 
       android:padding="10dp" 
       android:weightSum="3"> 

       <android.support.v7.widget.CardView 
        android:id="@+id/cardViewDemo2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        app:cardCornerRadius="10dp"> 

        <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:scaleType="fitXY" 
         android:src="@drawable/demo_one" /> 

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

       <android.support.v7.widget.CardView 
        android:id="@+id/cardViewDemo3" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_below="@id/cardViewDemo2" 
        android:layout_marginTop="5dp" 
        android:layout_weight="2" 
        app:cardCornerRadius="10dp"> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:background="#e9cca8"> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerInParent="true" 
          android:text="DEMOVIDEOONE" 
          android:textColor="#fff" 
          android:textSize="15sp" 
          android:textStyle="bold" /> 

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


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

    </LinearLayout> 

</RelativeLayout> 

回答

3

添加app:cardBackgroundColor="#e9cca8"app:cardBackgroundColor="#e4a455"和您的孩子的RelativeLayout和LinearLayout中

去除背景你有3 CardView ,在第三张CardView中,您只有ImageView,因此使用CardView可以更好地使用圆角图像视图。

+0

只需将'cardCornerRadius'添加到它。 – Dennis

+0

丹尼斯,cardRadiud已经在那儿了,问题在于孩子背景 –

+0

@Dennis你还看过我的代码吗? –

1
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:crad_view="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#ffffff" 
tools:context="com.software_solutions.optimus_tech_project201709.CourseSelect.CourseSelectionActivity"> 

<Button 
    android:id="@+id/register" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:text="Register" /> 


<Button 
    android:id="@+id/you" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:text="you" /> 

<ImageView 
    android:id="@+id/dialogImageView" 
    android:layout_width="match_parent" 
    android:layout_height="220dp" 
    android:scaleType="fitXY" 
    android:src="@drawable/dialog" 
    android:text="Hello" /> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/dialogImageView" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="-180dp" 
    android:gravity="center" 
    android:orientation="vertical"> 

    <ImageView 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:src="@drawable/select_course" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:text="SELECT A COURSE" 
     android:textColor="#ffffff" 
     android:textSize="25dp" 
     android:textStyle="bold" /> 
</LinearLayout> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="OK" /> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/dialogImageView" 
    android:orientation="vertical" 
    android:weightSum="2"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerViewSelectCourse" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:padding="5dp" /> 


    <android.support.v7.widget.CardView 
     android:id="@+id/cardViewDemo1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="10dp" 
     android:layout_weight="1" 
     android:elevation="3dp" 
     card_view:cardCornerRadius="0dp" 
     card_view:cardElevation="3dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#e4a455" 
      android:orientation="vertical" 
      android:padding="10dp" 
      android:weightSum="3"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/cardViewDemo2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       card_view:cardCornerRadius="4dp" 
       card_view:cardElevation="0dp"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="fitXY" 
        android:src="@drawable/demo_one" /> 

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

      <android.support.v7.widget.CardView 
       android:id="@+id/cardViewDemo3" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@id/cardViewDemo2" 
       android:layout_marginTop="5dp" 
       android:layout_weight="2" 
       app:cardCornerRadius="10dp"> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="#e9cca8"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="DEMOVIDEOONE" 
         android:textColor="#fff" 
         android:textSize="15sp" 
         android:textStyle="bold" /> 

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


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

</LinearLayout> 

+0

我改变了我的代码.......再次看看。谢谢 –

+0

我在回答中编辑了你的代码。现在试试 –

相关问题