Java 如何设计Android覆盖布局

Java 如何设计Android覆盖布局,java,android,Java,Android,我正在尝试制作一个警报对话框,该对话框将显示如图所示。 我试图使用框架布局,但不能使它像图片一样正确。在我当前的布局中,我使用了imageView和textview <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <FrameLayout android:layout_width="fill

我正在尝试制作一个警报对话框,该对话框将显示如图所示。 我试图使用框架布局,但不能使它像图片一样正确。在我当前的布局中,我使用了imageView和textview

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

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src=""/>
<TextView 
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@strings/text"
/>
</FrameLayout>
<!---<other layouts--->

</LinearLayout>


框架布局将堆叠视图,导致它们彼此重叠。如果你想要一个直接在另一个上面,考虑使用方向设置为垂直的A。 更新:尝试此操作,将框架布局替换为线性布局:

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

    <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@strings/text"
    />

    <ImageView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src=""/>

</LinearLayout>


显然,用图像填充ImageView的
src
参数。

创建一个活动,它代表您的覆盖

把这个放在你的onCreate中

requestWindowFeature(窗口。功能\u无\u标题)

将其放入styles.xml中

  <style name="FloatingPopup" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowNoTitle">true</item>
</style>

@android:彩色/透明
@android:彩色/透明
真的
真的
在您的手册中,声明看起来像覆盖图的活动,并添加主题

<activity
        android:name=".YourOverlayActivity"
        android:screenOrientation="portrait"
        android:theme="@style/FloatingPopup" >
    </activity>


它看起来像是一个半透明的活动,现在您可以使用xml布局编辑器进行自定义。

发布一些代码,以便我们可以看到您迄今为止所尝试的内容。您好,您可以使用带有transparence@wyoskibum添加了我的代码。。请看一看,我实际上是想把它做成我所附的图片。但是我不知道如何使用framelayout来实现这一点。@jquery404您的意思是希望布局像图像一样,还是只希望它看起来像一个具有模式背景的对话框?在任何情况下,请尝试我上面的布局代码。
<activity
        android:name=".YourOverlayActivity"
        android:screenOrientation="portrait"
        android:theme="@style/FloatingPopup" >
    </activity>