簡體   English   中英

應用小部件布局警告

[英]App Widget Layout warning

在開發者指南中 ,建議對App Widget使用以下布局。

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="@dimen/widget_margin">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@drawable/my_widget_background">

    </LinearLayout>

</FrameLayout>

Eclipse自然會發出警告, 此LinearLayout布局或其FrameLayout父級是無用的 這是正確的嗎? 我可以刪除LinearLayout嗎?

這實際上取決於小部件的內容。 您是否需要LinearLayout或FrameLayout才能正確定位內容? 根據您的問題,您無法回答該問題。 但是,如果是LinearLayout,則以下內容與上面的布局相同:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_margin="@dimen/widget_margin"
    android:background="@drawable/my_widget_background">
</LinearLayout>

請注意,我添加了layout_margin屬性而不是使用填充,因為無論您定義哪種填充,都會繪制背景。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM