1

タイトルの正しい単語が見つからないと思うので、正しく説明しようと思います。

だから私は私のレイアウトのバックラウンドのためにこの画像を持っています: http://imageshack.us/photo/my-images/607/fond1g.png/

そして、ボタンを正しくはめ込みたいと思います。

左右に透明感があるからです。したがって、ボタンはシートを超えています。

「これは透明性で、何も欲しくない」という言葉はありますか?または「ねえ、これは私がすべてを置きたい場所(シート)ですか?

別のLinearLayoutを配置しようとしましたが、適切な幅を指定する方法がわかりません。

ありがとう

4

3 に答える 3

1

あなたの質問から、背景画像の左右の透明なエッジにボタンを配置することは避けたいと思います。android:layout_marginLeftこれにはとを使用できますandroid:layout_marginRight。コードの場合、次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical"
 android:background="@drawable/fond"
>


<ImageView
    android:id="@+id/imageView1"
    android:contentDescription="@string/desc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/top" 
    android:layout_gravity="top" 
    android:adjustViewBounds="true" 
/>

<LinearLayout 
    android:layout_below="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/fond1"
    >

    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp" <!--Use the correct dp value, i just use it for example -->
        android:layout_marginRight="30dp" <!--Use the correct dp value, i just use it for example -->
        android:weightSum="3"
        >

        <Button 
            android:id="@+id/button_garçon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Bg"
            android:background="@drawable/button_purple" 
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:onClick="actionGarçon"
        />
        <Button 
            android:id="@+id/button_mixte"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Bm"
            android:background="@drawable/button_purple" 
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:onClick="actionMixte"
        />

        <Button
            android:id="@+id/button_fille"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Bf"
            android:background="@drawable/button_purple" 
            android:layout_weight="1"
            android:textColor="#ffffff"
            android:onClick="actionFille"           
        />

    </LinearLayout>



</LinearLayout>  

</LinearLayout>
于 2012-07-27T15:06:49.900 に答える
0

を使用しているLinearLayout場合は、画像の背景を設定できます。次に、の中に何でも入れることができLinearLayout、すべてが画像の中に正しく収まります。

例えば:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"       
    android:background="#ffffff"
    android:orientation="vertical">

    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="320dp"
        android:layout_height="512dp"       
        android:background="@drawable/scaled"
        android:orientation="vertical" >

    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="25dp"        
        android:text="Button" />

</LinearLayout>

ここに画像の説明を入力してください

お役に立てば幸いです。

于 2012-07-27T14:56:18.850 に答える
0

これは私のコードの典型的な部分です:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:background="@drawable/fond"
   >


    <ImageView
        android:id="@+id/imageView1"
        android:contentDescription="@string/desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/top" 
        android:layout_gravity="top" 
        android:adjustViewBounds="true" 
    />

    <LinearLayout 
        android:layout_below="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/fond1"
        >

        <LinearLayout 
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3"
            >

            <Button 
                android:id="@+id/button_garçon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Bg"
                android:background="@drawable/button_purple" 
                android:layout_weight="1"
                android:textColor="#ffffff"
                android:onClick="actionGarçon"
            />
            <Button 
                android:id="@+id/button_mixte"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Bm"
                android:background="@drawable/button_purple" 
                android:layout_weight="1"
                android:textColor="#ffffff"
                android:onClick="actionMixte"
            />

            <Button
                android:id="@+id/button_fille"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Bf"
                android:background="@drawable/button_purple" 
                android:layout_weight="1"
                android:textColor="#ffffff"
                android:onClick="actionFille"           
            />

        </LinearLayout>



    </LinearLayout>  

</LinearLayout>
于 2012-07-27T14:59:58.547 に答える