gpt4 book ai didi

android - 超出背景图像的按钮

转载 作者:行者123 更新时间:2023-11-30 04:05:50 25 4
gpt4 key购买 nike

我想我找不到标题的正确词,所以我会尝试正确解释。

所以我有这张图片作为我的布局的背景: http://imageshack.us/photo/my-images/607/fond1g.png/

我希望按钮能正确地放入其中。

因为左右两边都有一些透明度。所以按钮在工作表之外。

有没有什么可以说“嘿,这是透明的,我不想要任何东西”?或者“嘿,这是我想放所有东西的地方(工作表)?

我试图放置另一个 LinearLayout,但我不知道如何给出合适的宽度。

谢谢

最佳答案

根据您的问题,我了解到您想避免将按钮放在背景图像的左右透明边缘中。您可以为此使用 android:layout_marginLeftandroid: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>

关于android - 超出背景图像的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com