[英]How can I achieve this design in android?
I need to achieve the following design for these buttons 我需要为这些按钮实现以下设计
I have all the images. 我有所有的图像。 The left round images with pressed state and normal The button text background images but they are a rectangle shape.
带有状态和正常状态的左轮图像按钮文本背景图像,但它们是矩形形状。
I am using a linear layout and table layout This is my XML code 我正在使用线性布局和表格布局这是我的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 & ATM" />
</TableRow>
This is the output I get 这是我得到的输出
How do I cut the left corners for the background and also how do I make the pressed states so that both background and left Image changes plus the text color also changes? 如何在背景上切掉左上角以及如何使按下状态变成背景和左图都改变以及文字颜色也改变?
Try the below code: 试试下面的代码:
I have written sample code for only single item.. 我只为单个项目编写了示例代码。
<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>
Hope it will help this code..!!! 希望它将对这段代码有所帮助.. !!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.