[英]How do I make my widget look like google calendar widget?
I'd like to make my widget as much consistent as possible with Google calendar widget. 我想使我的窗口小部件与Google日历窗口小部件尽可能保持一致。 See the image link (sorry I don't have enough reputation to paste the image).
查看图片链接(很抱歉,我没有足够的声誉来粘贴图片)。 Colors are used to identify how much space each element takes.
颜色用于标识每个元素占用的空间。
widget.xml widget.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="@drawable/appwidget_dark_bg_clickable">
<LinearLayout
android:id="@+id/configureButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/refreshButton"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical"
android:background="#aa999966">
<TextView
android:id="@+id/headerTextView"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|left"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_above="@+id/footerTextView"
style="@style/headerTextStyle"
android:text="Channel"/>
<TextView
android:id="@+id/footerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom|left"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
style="@style/footerTextStyle"
android:text="last update: just started"/>
</LinearLayout>
<ImageView
android:id="@+id/refreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#aa8888bb"
android:src="@drawable/ic_refresh_white_36dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical"/>
</RelativeLayout>
<GridView
android:id="@+id/fieldsGridView"
android:numColumns="1"
android:gravity="center"
android:stretchMode="columnWidth"
android:background="@color/white"
android:layout_below="@+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:clipToPadding="false">
</GridView>
<TextView
android:id="@+id/empty_view"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/headerLayout"
android:gravity="center"
style="@style/emptyTextStyle"
android:text="Empty"/>
</RelativeLayout>
</FrameLayout>
list_item.xml list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/appwidget_dark_bg_clickable"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<TextView
android:id="@+id/fieldNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/fieldValueTextView"
android:background="#aaff0000"
style="@style/fieldNameTextStyle"/>
<TextView
android:id="@+id/fieldValueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:gravity="center_vertical|right"
android:background="#aa00ff00"
style="@style/fieldValueTextStyle"/>
</RelativeLayout>
My questions: 我的问题:
android:paddingLeft="8dp"
and android:paddingRight="8dp"
android:paddingLeft="8dp"
和android:paddingRight="8dp"
,也存在某种填充 Thanks 谢谢
Answering my own question after some research: 经过研究后回答我自己的问题:
1. Header shape 1.标题形状
A drawable shape can be used. 可以使用可绘制的形状。 It is a very simple solution and no png editing is involved.
这是一个非常简单的解决方案,不涉及png编辑。
widget_header_background.xml in res/drawable res / drawable中的widget_header_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="3dp"
android:topRightRadius="3dp"/>
<solid android:color="#ffff0000"/>
<stroke
android:color="#ffff0000"
android:width="1dp"/>
</shape>
using android:background="@drawable/widget_header_background"
in widget.xml 在widget.xml中使用
android:background="@drawable/widget_header_background"
2. Extra space in the listview 2.列表视图中的多余空间
Use another drawable shape 使用其他可绘制形状
widget_header_background.xml widget_header_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:radius="3dp"/>
<solid android:color="@color/grey"/>
<stroke
android:color="@color/grey"
android:width="1dp"/>
</shape>
3. Listview divider space 3. Listview分隔符空间
Add 加
android:divider="#ffffff"
android:dividerHeight="4dp"
in your listview
在您的
listview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.