FrameLayout中的元素是不可见的

时间:2016-11-13 19:26:52

标签: android android-layout invisible android-framelayout

我是Android开发的新手。 试图将Button和ImageView放在FrameLayout中,但它们是不可见的(它们确实存在于布局上,但未绘制)。

我的布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/OuterFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/flb1_off">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/show_dialog"
        android:id="@+id/showDialogBtn"
        android:onClick="showDialog"
        android:layout_gravity="center"
        android:background="#123456"
        android:textColor="@color/abc_background_cache_hint_selector_material_dark"
        android:visibility="visible" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/flb"
        android:layout_gravity="bottom"
        android:contentDescription="@string/content_desc" />

</LinearLayout>

api版本是19。 有趣的是按钮clickHandler工作正常,但按钮本身是不可见的。

如上所述here,我将所有孩子都置于单一子视图中,但没有成功。

我做错了什么?

2 个答案:

答案 0 :(得分:0)

替换android:前景到android:后台修复它,提供SHAH MD MONIRUL ISLAM

答案 1 :(得分:0)

你的问题来自这条线:

android:foreground="@drawable/flb1_off"

你需要改变它。

相关问题