如何实现以下目标

时间:2014-08-16 08:50:24

标签: android android-layout

如何获得以下图片 背景黄色 2.右上方的选择图像。 3.中间的其他图像 4.文字可根据需要高于或低于

如何通过按钮或textview或视图实现此目的

image

2 个答案:

答案 0 :(得分:1)

使用RelativeLayout。代码将以某种方式看起来像这样:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <!-- First image -->
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />        
    <!-- Second image -->
    <ImageView
        android:id="@+id/mySecondImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/mySecondImage" />
</RelativeLayout

答案 1 :(得分:1)

RelativeLayout将解决此问题


<强>代码

<RelativeLayout
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="center"
    android:background="#000000" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:text="Text" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:src="@drawable/ic_launcher" />

</RelativeLayout>


<强>快照 ::

enter image description here


{编辑}

您无法将此视为单一视图

<强> 解决方法

  • 您可以使用背景drawable
  • 实现此单视图
  • 制作背景图像,同时将图像放在另一张图像中
  • 将最终图像设置为按钮的背景
  • 您甚至可以使用按钮的选择器来提供角落背景
相关问题