繁体   English   中英

如何在android中实现此设计?

[英]How can I achieve this design in android?

我需要为这些按钮实现以下设计

在此处输入图片说明

我有所有的图像。 带有状态和正常状态的左轮图像按钮文本背景图像,但它们是矩形形状。

我正在使用线性布局和表格布局这是我的XML代码

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/stbk"
android:gravity="center"
android:orientation="vertical" >

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:gravity="center" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/scttransband" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/acc" />


        <Button
            android:id="@+id/accountButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:gravity="left|center"
            android:paddingLeft="15dp"
            android:text="My Account" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@drawable/scttransband" >

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="60dp"
            android:layout_height="64dp"
            android:src="@drawable/dd" />

        <Button
            android:id="@+id/locateButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:gravity="left|center"
            android:paddingLeft="15dp"
            android:text="Locate Branches &amp; ATM" />
    </TableRow>

这是我得到的输出

在此处输入图片说明

如何在背景上切掉左上角以及如何使按下状态变成背景和左图都改变以及文字颜色也改变?

试试下面的代码:

我只为单个项目编写了示例代码。

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="-20dp"
        android:layout_toRightOf="@+id/imageView1"
        android:background="YOUR_COLOR"
        android:gravity="center"
        android:padding="8dp"
        android:text="YOUR_TEXT"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:src="YOUR_CIRCLE_IMAGE" />

</RelativeLayout>

希望它将对这段代码有所帮助.. !!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM