1

ビューのようなボックスで XML コードの要素をラップするにはどうすればよいですか? つまり、境界線のあるボックスにグループ化されているように見えるようにしたいということです。

<Button
    android:id="@+id/carbgraph"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="230dp"
    android:layout_y="378dp"
    android:text="Button" />

<ProgressBar
    android:id="@+id/progressBarforcals"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    android:layout_x="15dp"
    android:layout_y="346dp" />

<TextView
    android:id="@+id/calsinmenu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="16dp"
    android:layout_y="320dp"
    android:text="TextView" />
4

3 に答える 3

5

ウィジェットをレイアウト (LinearLayout など) に配置し、このレイアウトの背景を次のように編集します。

<LinearLayout 
   ...
   android:background="@drawable/background"
</LinearLayout>

次に、background.xml という名前のドローアブル フォルダーに XML ファイルを作成します。

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke 
        android:width="3dp" 
        android:color="#838c7f">
    </stroke>

    <padding 
        android:left="3dp" 
        android:top="3dp"
    android:right="3dp" 
    android:bottom="3dp">
    </padding>

    <corners android:radius="4dp" />

    <gradient 
        android:startColor="@color/background_start" 
        android:endColor="@color/background_end"/>
</shape>
于 2012-05-04T18:25:05.333 に答える
0
You can set background of your layout

box.png という名前の境界線を持つボックスのように見える 1 つの画像を作成し、この画像を drawable に配置します

ex:

    <LinearLayout 
    .. ..  
        android:backgroud="@drawable/box.png">

<Button
    android:id="@+id/carbgraph"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="230dp"
    android:layout_y="378dp"
    android:text="Button" />

<ProgressBar
    android:id="@+id/progressBarforcals"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    android:layout_x="15dp"
    android:layout_y="346dp" />

<TextView
    android:id="@+id/calsinmenu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="16dp"
    android:layout_y="320dp"
    android:text="TextView" />


    </LinearLayout>
于 2012-05-04T18:25:14.223 に答える