2011-01-22 56 views
0

我有一個n應用程序小部件,幾乎可以工作,有一個怪癖。我在窗口小部件中有一個LinearLayout,並且可以將我的數據行添加到它中。似乎沒有任何明顯的方式讓我說出線性佈局有多大,以及給定的行是否合適,因此我只是添加整個數據集(因爲它不是很大)。我的佈局中的文本會在底部裁剪,這正是我所期望的。但是,它旁邊的ImageView不會被裁剪,而是被縮放。坦率地說,它看起來很愚蠢。RemoteViews中的LinearLayout沒有裁剪ImageView

如果有一種方法可以讓我判斷一行是否適合我的LinearLayout,那就太棒了。如果有辦法我可以告訴它裁剪我的圖像,那也可以。這是剪裁的樣子。

爲我添加(如果這裏有一個混日子,那麼這可能是我申請匿名)的行佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <ImageView 
     android:id="@+id/checkbox" 
     android:layout_width="28sp" 
     android:layout_height="28sp" 
     android:src="@drawable/check_off" 
     android:layout_marginLeft="5dp" 
     android:layout_marginTop="1dp" 
     android:layout_alignParentLeft="true"/> 
    <TextView 
     android:id="@+id/textview" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:textSize="16sp" 
     android:minHeight="28sp" 
     android:paddingLeft="5dp" 
     android:layout_centerVertical="true" 
     android:layout_alignWithParentIfMissing="true" 
     android:layout_toRightOf="@id/checkbox"/> 
</RelativeLayout> 

編輯:針對行的容器是一個簡單的LinearLayout:

<LinearLayout 
    android:id="@+id/list_items" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_above="@id/logo" 
    android:layout_marginBottom="4dp" 
    android:padding="1dp" 
    android:orientation="vertical" 
    android:background="@drawable/widget_background"/> 
+0

它可以更好,如果你添加你的主要佈局信息。在其中添加 – 2011-01-22 03:17:14

+0

我在這裏添加了LinearLayout,雖然它很無聊。 – jjb 2011-01-24 21:42:33

回答

0

事實證明,給予,而不是「WRAP_CONTENT」是對應於行特定的高度(30sp,此佈局)的RelativeLayout的固定問題。現在圖像正確地播種。