【发布时间】:2014-02-14 16:09:29
【问题描述】:
伙计们,如果我有这样的布局
<?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"
android:background="@drawable/deals_list_item_bckg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:background="@drawable/deals_list_item_background"
android:clickable="true"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="85dp"
android:layout_height="50dp"
android:scaleType="fitXY"
android:src="@drawable/btn_unpressed" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|right"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="My Account"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
结果是
有没有办法编写选择器,当按下状态时只改变 imageView 的 img
喜欢这个
或者请告诉我我该怎么做这样的按钮,因为问题是按钮的右侧部分也需要背景图像,而左侧部分是图像视图,当按下右侧部分(布局)时必须更改它的图像
【问题讨论】:
-
给ImageView的imageDrawable设置一个StateListDrawable