【问题标题】:Bring to front a view over foreground image of a frameLayout在 frameLayout 的前景图像上显示视图
【发布时间】:2016-04-24 19:29:49
【问题描述】:

我有一个带有前景图像的框架布局,如下所示。在我的框架布局中,我有一个文本视图,但由于它位于前景图像的后面,所以看不到它。如何将它放在前景图像的前面?

<FrameLayout           
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/foreground_image"
android:orientation="vertical">

<RelativeLayout
    android:id="@+id/rel"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/myImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:src="@drawable/dreams" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/myImageView"
        android:layout_gravity="center"
        android:text="MY TEXT"
        android:textColor="#ffffff"
        android:textSize="20sp" />
</RelativeLayout>

</FrameLayout>

【问题讨论】:

    标签: android android-relativelayout android-framelayout background-foreground bringtofront


    【解决方案1】:

    我会将图像作为 ImageView 放置在 FrameLayout 中,而不是使用前景。然后您可以更轻松地控制各种事物的绘制顺序。 前景将始终覆盖内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多