Android 我怎样才能把照片放在前景上?

Android 我怎样才能把照片放在前景上?,android,background,Android,Background,在我的应用程序中,有一个列表视图和两张图片。不幸的是,前景图片是我想要的背景图片。我想改变一下优先级。有人能帮忙吗?:) ……一个视图只能设置一个背景。如果您希望以某种方式组合两个图像,请尝试在xml文件中这样做。然后简单地将其设置为背景 或者在java代码中尝试使用Drawable类或GradientDrawable或其他东西 最后,关于失败,有一张可爱的画布可供帮助) PS没有listview请尝试更改xml文件中视图的顺序。如果在同一位置上有多个视图,则稍后在xml文件中声明的视图将与

在我的应用程序中,有一个列表视图和两张图片。不幸的是,前景图片是我想要的背景图片。我想改变一下优先级。有人能帮忙吗?:)



……一个视图只能设置一个背景。如果您希望以某种方式组合两个图像,请尝试在xml文件中这样做。然后简单地将其设置为背景

或者在java代码中尝试使用Drawable类或GradientDrawable或其他东西

最后,关于失败,有一张可爱的画布可供帮助)


PS没有listview

请尝试更改xml文件中视图的顺序。如果在同一位置上有多个视图,则稍后在xml文件中声明的视图将与首先声明的视图重叠。如果不起作用,请尝试使用bringToFront()方法更改顺序

  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hatter"
tools:context="hu.szada.nagyteszt.SecondActivity"
xmlns:ads="http://schemas.android.com/apk/res-auto">


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">


    <ImageButton
        android:id="@+id/gratulauzenet"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:onClick="onClick"
        android:background="@drawable/gratulalok"
        android:layout_centerHorizontal="true"
        android:visibility="visible"/>

    <RelativeLayout
        android:layout_width="250dp"
        android:layout_height="130dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp" >


        <ImageButton
            android:id="@+id/Szintelso"
            android:layout_width="250dp"
            android:layout_height="120dp"
            android:background="@drawable/egy"
            android:onClick="onClick" />

        <TextView
            android:id="@+id/Szegytextegy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/Szegytextketto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="180dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp" />


    </RelativeLayout>

      <RelativeLayout
        android:layout_width="250dp"
        android:layout_height="120dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="200dp" >

        <ImageButton
            android:id="@+id/Szintmasodik"
            android:layout_width="250dp"
            android:layout_height="120dp"
            android:background="@drawable/kettozart"
            android:onClick="onClick" />

        <TextView
            android:id="@+id/Szkettotextegy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/Szkettotextketto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="180dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/Szkettotextharom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true"
            android:textSize="15dp"/>
    </RelativeLayout>

      <RelativeLayout
        android:layout_width="250dp"
        android:layout_height="120dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="350dp" >

        <ImageButton
            android:id="@+id/Szintharmadik"
            android:layout_width="250dp"
            android:layout_height="120dp"
            android:background="@drawable/haromzart"
            android:onClick="onClick" />

        <TextView
            android:id="@+id/Szharomtextegy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/Szharomtextketto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="180dp"
            android:layout_marginTop="40dp"
            android:textSize="20dp"
            android:visibility="invisible" />

        <TextView
            android:id="@+id/Szharomtextharom"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true"
            android:textSize="15dp"/>
    </RelativeLayout>
View v = findViewById(R.id.myView);
v.bringToFront();