gpt4 book ai didi

android - 如何使用android设置带有书架背景的书籍图像?

转载 作者:行者123 更新时间:2023-11-29 02:08:18 25 4
gpt4 key购买 nike

我想在android程序中以书架图片为背景显示每本书的正面图片?

背景图片---->书架图片前景图片------>书籍首页图片

XML 文件:

<?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/iphone" >
</LinearLayout>

最佳答案

我建议您改用Relative Layout。然后使用 Image ViewImage Button 并将那些 Image ViewsImage Buttons 的背景设置为封面的书。使用 Relative Layouts,您可以通过单击鼠标拖动项目并将它们放置在布局中的任意位置。利用这一优势,将那些 Image ViewsImage Buttons 放置在您想要的任何位置,然后设置书籍封面的各个背景。

编辑: 代码添加:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/iphone" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="36dp"
android:layout_marginTop="58dp"
android:src="@drawable/ic_launcher" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/imageView1"
android:layout_marginRight="72dp"
android:src="@drawable/ic_launcher" />

<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:src="@drawable/ic_launcher" />

<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_below="@+id/imageView3"
android:layout_marginTop="46dp"
android:src="@drawable/ic_launcher" />

<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/imageView2"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />

</RelativeLayout>

也许是这样的。但是您需要更改的内容很少,例如 android:src="@drawable/ic_launcher" 。我懒惰地添加了 ic_launcher。所以,你必须用你的书的封面来代替它。您可能需要更改的另一件事是重新定位 Image Views。我猜就是这样。希望这可以帮助。

关于android - 如何使用android设置带有书架背景的书籍图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8754377/

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