如何使小部件更小?

时间:2013-07-25 08:58:33

标签: java android xml android-layout layout

我有一个小部件,看起来它在一个设备中的边界

并且看起来更宽广:

我想:

enter image description here

我有:

enter image description here

在一个较小的屏幕中我有:

enter image description here

请注意外边框(黑线)

我该如何解决这个问题?

<!--  -->

<RelativeLayout
    android:id="@+id/layout_main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center_vertical"
    android:gravity="center_vertical"
    android:orientation="horizontal" >

    <RelativeLayout
        android:id="@+id/layout_status_image"
        android:layout_width="82dp"
        android:layout_height="fill_parent"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/image_status_bg"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:src="@drawable/widget_bg_status_nodata"
            android:visibility="invisible" />

        <ImageView
            android:id="@+id/image_status"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="9dp"
            android:layout_marginTop="19dp"
            android:src="@drawable/widget_icon_no_data"
            android:visibility="visible" />
        <!--
                          Layout is necessary because the setVisibility of ProgressBar is not working 
                          through remote views in 2.1. So wrapped by this layout 
        -->

        <FrameLayout
            android:id="@+android:id/widget_progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="26dp" >

            <ProgressBar
                style="?android:attr/progressBarStyle"
                android:layout_width="39dp"
                android:layout_height="39dp"
                android:indeterminateOnly="true"
                android:orientation="vertical" />
        </FrameLayout>
    </RelativeLayout> <!-- Status image layout -->


    <!--
                        ========================================================================
                        * Information layout - contains all the texts 
                        ========================================================================
    -->

    <LinearLayout
        android:id="@+id/layout_information"
        android:layout_width="155dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/layout_status_image"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/text_view_destination"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="11dp"
            android:paddingTop="11dp"
            android:text="\@ Home in"
            android:textColor="@color/solid_white"
            android:textSize="19sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/text_view_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:paddingLeft="9dp"
            android:textColor="@color/solid_white"
            android:textSize="32sp"
            android:textStyle="normal" />
    </LinearLayout> <!-- Information layout -->
    <!--
                        ========================================================================
                        * Action layout - action buttons container
                        ========================================================================
    -->

    <LinearLayout
        android:id="@+id/layout_action"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_toRightOf="@+id/layout_information"
        android:gravity="center"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/image_action"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:src="@drawable/widget_bt_drive_disabled" />

        <TextView
            android:id="@+id/text_view_action"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="Drive!"
            android:textColor="@color/disabled_white"
            android:textSize="15sp"
            android:textStyle="bold" />
    </LinearLayout> <!-- Action layout -->

</RelativeLayout> <!-- main view -->

1 个答案:

答案 0 :(得分:0)

使用:

android:layout_marginRight =“{你需要移动白框的像素数量}}”