【发布时间】:2015-04-23 07:45:11
【问题描述】:
我使用下面的代码将我的按钮设计为圆形,然后我想在按钮上显示一些文本,所以我使用了框架布局,然后我在按钮上放置了一些文本。 现在的挑战是我的按钮仍然存在。它对点击没有任何影响 其中drawable和src都用于圆形按钮和按钮上的图像(分别)。
现在我的按钮不会对点击我的设计产生任何影响。
<FrameLayout>
<ImageButton
android:id="@+id/btn_profile_view"
android:layout_width="70dp"
android:layout_height="67dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:onClick="compareButtonClick"
android:background="@drawable/roundedbutton"
android:src="@drawable/ic_action_person" />
<TextView
android:layout_width="45dp"
android:layout_height="20dp"
android:layout_gravity="bottom"
android:layout_marginLeft="38dp"
android:clickable="false"
android:text="@string/profile"
android:textColor="@color/btn_txt" >
</TextView>
</FrameLayout>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#D3D3D3" />
<corners
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"
android:topLeftRadius="8dip"
android:topRightRadius="8dip" />
【问题讨论】:
-
为什么没有指定 framelayout 尺寸属性?
-
并在您尝试获取 onclick 回调的位置显示您的代码
-
我不需要框架布局属性,因为我将框架布局放在表格布局、表格行布局中,并且我使用表格行中的权重属性在单行上显示 3 个图像按钮。
-
jave 代码只是 onclicklistner 从一个活动移动到另一个活动......在每个按钮上
标签: android xml imagebutton