开发者

How to create android activity that shows at specified screen position?

开发者 https://www.devze.com 2023-03-19 01:14 出处:网络
My curre开发者_高级运维nt layout displays activity that is not full screen (that\'s OK). <?xml version=\"1.0\" encoding=\"utf-8\"?>

My curre开发者_高级运维nt layout displays activity that is not full screen (that's OK).

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="100dip"
android:layout_height="200dip" >

<TextView android:layout_height="wrap_content" android:id="@+id/textView1"
    android:layout_width="fill_parent" android:text="@string/hello"></TextView>

I also added android:theme="@android:style/Theme.Translucent" to manifest for my activity.

My 200x100dip activity now shows in the upper left corner. How can i specify position of my linear layout (or my activity)?


You can use either FrameLayout or RelativeLayout as outer most layout for this. Ant then use absolute position in dp or android:layout_centerInParent or similar.


I believe your Activity´s outmost layout element (LinearLayout) will be placed in a FrameLayout that is the parent given from Android. I suggest you let your outmost layout match_parent/fill_parent in layout_height and _width and then center the content inside it with gravity="center" on your outmost layout. By letting the outmost layout being transparent and not catch click element it will appear as layout in the middle where elements behind is visible. If Im correct guessing that's what you want to achieve here.


put that layout in another absolute layout in which you use android:layout_width="fill_parent" and android:layout_height="fill_parent" the other thing you can do is to use this: http://www.droiddraw.org/ you can move your elements around manually with that and it will give you the XML code that is used to do that. I found it very useful in laying out XML in android.

0

精彩评论

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