开发者

Positon an Acitvity applied with a theme dialog at a particular x, y position

开发者 https://www.devze.com 2023-04-06 13:10 出处:网络
I would like to place the dialog on a particular positi开发者_JS百科on on the screen(-10px from top and -5px from let).

I would like to place the dialog on a particular positi开发者_JS百科on on the screen(-10px from top and -5px from let).

I did apply the theme and added the android:scrollX, android:scrollY, but it doesn't seem to work.

Any solutuions?

Below is my styling xml.

<style name="Theme.MyDialog1" parent="android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:layout_width">300dp</item>
    <item name="android:scrollX">-10dp</item>
    <item name="android:scrollY">-5dp</item>
</style>

EDIT:

I have also tried android:layout_x and android:layout_y, but no use!

This is the one that I have ![enter image description here][1]

but what I really want is which is just below the signup logo positioned at a particular x and y positive!!!!![enter image description here][2]


This is the code!

LayoutParams lp = this.getWindow().getAttributes();
             lp.x=50;lp.y=20;lp.width=100;lp.height=200;lp.gravity=Gravity.TOP | Gravity.LEFT;
            lp.dimAmount=0;            
            lp.flags=LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_NOT_TOUCH_MODAL;
this.setContentView(view, lp);


Don't extend the dialog theme extend the panel theme.

<style name="Theme.CustomPanel" parent="@android:style/Theme.Panel">        
         <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
         <item name="android:backgroundDimEnabled">true</item>
    </style>

This creates a window similar to a dialog except it doesn't center it like a dialog does. Then create an activity like you normally would then start it.

To make it 5px from left and 10px from top just put padding on your layout

 <!-- res/layout/your_layout.xml -->
   <FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:paddingTop="10px"
  android:paddingLeft="5px"></FrameLayout>

And of course your activity should just be normal like

public class NonCenteredDialogActivity extends Activity{
      protected void onCreate(Bundle bundle){
          super.onCreate(bundle);
          setContentView(R.layout.your_layout);
      }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号