Android小部件太小了

时间:2013-07-27 12:54:14

标签: android android-widget

我希望我没有错过具有相同主题的另一个主题,但我一直在寻找解决方案。

我实施了一个使用android:minSdkVersion="10"targetSdkVersion="17"

的Android应用程序

在这个应用程序中,我使用以下布局定义了一个小部件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/account_info_widget_content"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@drawable/appwidget_dark_bg_clickable"
              android:baselineAligned="false"
              android:layout_margin="0dp"
              android:gravity="center_vertical"
              android:orientation="horizontal" 
              >
  <ImageView
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginLeft="@dimen/list_entry_padding_horizontal"
    android:src="@drawable/app_icon" />
  <ImageView
    android:layout_width="1dp"
    android:layout_height="match_parent"
    android:layout_marginRight="@dimen/default_padding"
    android:background="@drawable/appwidget_divider" />

  <LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_vertical"
  >
    <TextView
      android:id="@+id/account_info_widget_btc"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textSize="@dimen/font_size_xlarge"
      android:singleLine="true"
      android:textColor="#eee"
    />
    <TextView
      android:id="@+id/account_info_widget_balance"
      android:layout_width="fill_parent"    
      android:layout_height="wrap_content"
      android:textSize="@dimen/font_size_xlarge"
      android:singleLine="true"
      android:textColor="#eee"
    />
  </LinearLayout>
</LinearLayout>

我的widget xml文件包含:

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
                android:initialLayout="@layout/account_info_widget_content"
                android:resizeMode="horizontal|vertical"
                android:minHeight="@dimen/cell_size_1"
                android:minWidth="@dimen/cell_size_3"
/>

Cell_size_1_3对于版本14定义为40dp / 180dp,对于其他版本定义为72dp / 220dp,如文档中所建议的。 在Android版本低于14版本的一切看起来都不错,但Android 4显示的小部件比其他所有小部件更平和更窄。

现在我发现如果我将目标SDK版本更改为10,那么小部件也可以在Android 4上运行。 是否有一点我错过了小部件定义或者你能给我一个提示,我该尝试什么? 非常感谢您的时间和帮助!

0 个答案:

没有答案