如何在 android 中设置图像背景和文本/图像
how to set background of an image and a text /image over it in android
我是 android 的新手,我已经将 psd 在线制作成 png,现在我有各种 png。
我需要设计 UI,其中我有一个背景图像和一个菜单图标图像
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/shape"
android:background="@drawable/shapes"
android:text="Button" />
我试图将它们设置为背景,但我有两张图片如何操作。,还在其上设置文本图片。
我的 psd 到 png link 是 here 我有多个图像。
我有 this image in center this in left and above it have to set this.
好的,试试这个
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#5A99A8" >
<ImageView
android:id="@+id/menu"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#40000000"
android:padding="12dp"
android:src="@drawable/your_menu_image" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/sett"
android:layout_toRightOf="@+id/menu"
android:gravity="center"
android:text="WELCOME MENU"
android:textColor="#FFF" />
<ImageView
android:id="@+id/sett"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="#40000000"
android:padding="12dp"
android:src="@drawable/your_settings_image" />
</RelativeLayout>
并使用颜色而不是图像来获得这种类型的标题栏
虽然这不是一个好的解决方案
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/shape"
android:drawableLeft="@drawable/abc"
android:drawableRight="@drawable/def"
android:background="@drawable/shapes"
android:text="Button" />
我是 android 的新手,我已经将 psd 在线制作成 png,现在我有各种 png。 我需要设计 UI,其中我有一个背景图像和一个菜单图标图像
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/shape"
android:background="@drawable/shapes"
android:text="Button" />
我试图将它们设置为背景,但我有两张图片如何操作。,还在其上设置文本图片。 我的 psd 到 png link 是 here 我有多个图像。
我有 this image in center this in left and above it have to set this.
好的,试试这个
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#5A99A8" >
<ImageView
android:id="@+id/menu"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#40000000"
android:padding="12dp"
android:src="@drawable/your_menu_image" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/sett"
android:layout_toRightOf="@+id/menu"
android:gravity="center"
android:text="WELCOME MENU"
android:textColor="#FFF" />
<ImageView
android:id="@+id/sett"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="#40000000"
android:padding="12dp"
android:src="@drawable/your_settings_image" />
</RelativeLayout>
并使用颜色而不是图像来获得这种类型的标题栏
虽然这不是一个好的解决方案
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/shape"
android:drawableLeft="@drawable/abc"
android:drawableRight="@drawable/def"
android:background="@drawable/shapes"
android:text="Button" />