【发布时间】:2013-12-19 17:21:03
【问题描述】:
我在线性布局中添加了 3 个按钮,并在我的活动中为它们分配了一个 onClick 侦听器,其中两个在运行代码时收缩并仅包装包含的文本,
点击后第三个会缩小:
我正在使用的按钮:
我在 XML 中使用的代码:
<LinearLayout
android:id="@+id/bottomButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="@+id/LivingRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ac_button_active"
android:text="Living Room"
android:textSize="20dp"
android:textColor="#00CCCC"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:layout_marginBottom="3dp"
android:layout_marginRight="3dp"
android:tag="pressed" />
<Button
android:id="@+id/NoAC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ac_button_inactive"
android:text="No AC"
android:textSize="20dp"
android:textColor="#00CCCC"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:layout_marginBottom="3dp"
android:layout_marginRight="3dp"
android:tag="transparent"/>
<Button
android:id="@+id/office"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ac_button_inactive"
android:text="Office"
android:textSize="20dp"
android:textColor="#00CCCC"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:layout_marginBottom="3dp"
android:layout_marginRight="3dp"
android:tag="transparent"/>
【问题讨论】:
-
你是在代码中修改视图吗?
-
按钮的背景是 ColorDrawable 吗?你能发布所有按钮的@drawable/ac_button_inactive 和背景吗?
-
您使用的是 9-patch 图像吗?
-
尺寸变大了一点,但还是同样的问题
-
问题可能出在您使用的背景可绘制对象上...
标签: android button background-image android-button