2017-08-27 55 views
0

我对android非常陌生,试图在xml中创建这样的设计。 image description here我如何在android xml设计中使用多个形状

我能够创建在圆圈和文本视图中有圆圈的设计的最左侧部分。 enter image description here

以下是我为上面创建的文件。

/drawable/design_circle.xml

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item 

    android:top="6dp" 
    android:right="6dp" 
    android:bottom="6dp" 
    android:left="6dp"> 
    <shape 
     android:shape="oval"> 
     <stroke 
      android:width="1dp" 
      android:color="#78d9ff"/> 
    </shape> 
</item> 
<item> 
    <shape 
     android:shape="oval"> 
     <stroke android:width="4dp" 
      android:color="#78d9ff"/> 
    </shape> 
</item> 

/layout/view.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 
<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="150dp" 
    android:layout_gravity="center" 
    > 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <TextView 
      android:id="@+id/ec_txtDate" 
      android:layout_width="120dp" 
      android:layout_height="120dp" 
      android:background="@drawable/design_circle" 
      android:text="09" 
      android:textAlignment="center" 
      android:gravity="center_vertical" 
      android:textStyle="bold" 
      android:textSize="50dp"/> 
    </RelativeLayout> 
</android.support.v7.widget.CardView> 

,但我不能够创造*十月*设计中必须与圆相邻的部分。先谢谢你。

+0

**''''''''''''''''''''''''''''可能是你想要的东西(即layrered drawables)。 [图层列表](https://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList) – MikeT

回答

0

如果您不想点击每个子部分,请改为使用图像。您完成了左侧,看起来我认为您会期待点击该圆圈,以便将图像变成两个你创建的图形的右侧图像视图

<android.support.v7.widget.CardView 
    android:layout_width="match_parent" 
    android:layout_height="150dp" 
    android:layout_gravity="center" 
    > 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center"//give this to align the objects in this view center alignment 
     android:orientation="vertical"//remove this because it is not relevant for a relative layout but relevant for linearlayout> 
     <TextView 
      android:id="@+id/ec_txtDate" 
      android:layout_width="120dp" 
      android:layout_height="120dp" 
      android:background="@drawable/design_circle" 
      android:text="09" 
      android:textAlignment="center" 
      android:gravity="center_vertical" 
      android:textStyle="bold" 
      android:textSize="50dp"/> 
     <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@+id/"ec_txtDate 
       android:src="@drawable/your_image.png" /> 
    </RelativeLayout> 
</android.support.v7.widget.CardView> 
+0

这不是可以点击的,我希望不同的textviews即日,月可以动态填充。 –

+0

您可以这样做,首先创建没有文字的图片,然后使用relativelayout在该图片的顶部创建文字浏览。 – Manoranjan

相关问题