0

我想要一个像this one那样设计的AppWidget。Android:AppWidget设计和布局

图片:

enter image description here

我已搜查如需协助网络,但找不到任何。

特别: 我想要一个appwidget至极由一个ImageButton的,和(在图片等上文)将被放置在它前面一个TextView。

迄今为止我发现的最接近的解决方案是通过relativeLayout,但它仍然没有将textView 放在imageButton上。

很高兴能为这样的AppWidgets设计提供任何帮助。

Thanks Advanced,Gal。

+1

查看我的回答[此问题](http://stackoverflow.com/questions/6522812/how-to-create-an-inbox-style-with-unread-count-widget-for-android/ 6522983#6522983)。 – 2011-10-10 22:04:53

+0

谢谢你,这是非常有益的:) – GalDude33

回答

0

使用此answer来解决它,(在评论中由alextsc链接)。

的相对布局确实被使用,我设法通过使用此配置,以达到预期的效果:

<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="wrap_content" android:layout_height="72dp"> 
     <ImageButton android:background="@null" android:layout_width="fill_parent" android:src="@drawable/phone_draw" android:layout_height="wrap_content" android:id="@+id/call" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"></ImageButton> 
     <TextView android:textColor="@color/green" android:textAppearance="?android:attr/textAppearanceMedium" android:id="@+id/missedCalls" android:layout_width="wrap_content" android:textStyle="bold" android:background="@drawable/missed_call_bg" android:text="3" android:gravity="center_vertical|center_horizontal" android:typeface="sans" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true"></TextView> 
</RelativeLayout> 

当图像按钮是大图标,TextView的是小柜台图标。

希望它能帮助你! =]

0

您可以使用RelativeLayout或FrameLayout。这些布局中的项目按照XML读取顺序添加,因此为了让您的TextView位于ImageView的正面,只需编写ImageView,然后再编写TextView。 然后将这些小部件视图中的每一个嵌套到GridLayout中,以获取该Homeview布局。

尝试查看布局下的API示例。那里有很好的例子。