2015-05-18 139 views
2

如何定制围绕弹出对话框的半透明区域的外观?也就是说,显示潜在活动的区域。android自定义对话框半透明边距

弹出活动正在开始

Intent intent = new Intent (app, MyPopup.class); 
app.startActivityForResult (intent, requestCode); 

这里app是当前活动。

XML文件的顶层是一个ScrollView。我试着在那里设置背景,但设置被忽略。另外,我尝试调整边距,但也忽略了这些边距。 (NB - 我现在认识到,利润只适用于LinearLayout中;忽略的问题,请。)例如:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="20dp" 
    android:maxWidth="200dp" > 

以上,保证金和maxWidth被忽略。

而且,我试着建立一个自定义样式:

<style name="PopupTheme" parent="android:style/Theme.Dialog"> 
    <item name="android:background">#FFF2F2F2</item> 
    <item name="android:textColor">#FF000000</item> 
    <item name="android:windowNoTitle">true</item>" 
    <item name="android:backgroundDimEnabled">false</item> 
    <item name="android:windowIsTranslucent">false</item> 
    <item name="android:windowBackground">@drawable/dialog_background</item> 
</style> 

在这种风格,backgroundDimEnabled确实有差别 - 它允许始发胡亚蓉在全亮度显示。但其他属性似乎被忽略。事实上,我尝试过的很多设置都没有效果,这让我相信,我错过了一些重要的“私人密码”设置,或者谷歌硬编码了太多的行为以使这些设置正常工作。

我可以添加另一层我所有的弹出窗口,在该层是全屏幕和不透光的方式我想,他有真正的对话放在最重要的是。如果有正确的方法来做我想做的事情,我宁愿不采取解决方法。

谢谢。

回答

0

有一个与滚动型问题,因为它从延伸的FrameLayout里,因为这不能适用利润率它。我可以做的一点是在ScrollView中创建一个LinearLayout并为其应用边距。

是这样的:

<ScrollView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="top" 
        android:layout_marginTop="30dp" 
        android:orientation="vertical" > 
</ScrollView> 
+0

你是什么意思“有一个与滚动型有问题”? –

+0

关于利润率,在你的情况。 –

+0

对。边距应该只适用于LinearLayout。那么,利润率对于手头的问题是一种冲击。 –