gravity

Dialog/DialogFragment宽度高度修改/全屏,自定义样式

妖精的绣舞 提交于 2019-11-30 12:57:17
其实Dialog, DialogFragment, Activity 能看到的界面,都是基于Window显示的; 也就是修改样式, 都是在修改window的样式; 所以,本质上方法都是一样的,唯一不同的就是获取window对象的方法不一样; Dialog 通过, getWindow() 获取; Activity 也是通过, getWindow() 获取; DialogFragment 则是getDialog().getWindow()获取; 有了window对象, 就可以开始本文了: 1:修改Dialog中window宽度和高度 //public static final int FILL_PARENT = -1; //public static final int MATCH_PARENT = -1; //public static final int WRAP_CONTENT = -2; dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//注意此处 dialog.setContentView(textView, new ViewGroup.LayoutParams(-2, -2)); dialog.getWindow().setLayout(-1, -2);/

Simulate “Newton's law of universal gravitation” using Box2D

吃可爱长大的小学妹 提交于 2019-11-30 12:16:13
问题 I want to simulate Newton's law of universal gravitation using Box2D. I went through the manual but couldn't find a way to do this. Basically what I want to do is place several objects in space (zero gravity) and simulate the movement. Any tips? 回答1: It's pretty easy to implement: for ( int i = 0; i < numBodies; i++ ) { b2Body* bi = bodies[i]; b2Vec2 pi = bi->GetWorldCenter(); float mi = bi->GetMass(); for ( int k = i; k < numBodies; k++ ) { b2Body* bk = bodies[k]; b2Vec2 pk = bk-

Change gravity of PopupWindow

血红的双手。 提交于 2019-11-30 10:27:27
I have a button that must show a popup window. And the popup window must be aligned with the right side of the button. That's how I do it. button.setOnClickListener( new View.OnClickListener() { @Override public void onClick( final View view ) { if(popup == null) { final View view = getLayoutInflater().inflate(R.layout.popup, null); popup = new PopupWindow(view); } if(popup.isShowing()) { popup.dismiss(); } else { popup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); popup.setFocusable(true); popup.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP

What is exact difference between gravity and layout_gravity [duplicate]

做~自己de王妃 提交于 2019-11-30 08:29:45
Possible Duplicate: Android - gravity and layout_gravity I have been working on android xml's. I have used android:layout_gravity="center" to align components in specific position. Now a days, when I was working on a Dialog like Activity , I came across android:gravity="center" . What I found there was, gravity was used to align its child to a specific position. I would share an example of what it is, android:gravity="center" <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="vertical" > <EditText

Simulate “Newton's law of universal gravitation” using Box2D

雨燕双飞 提交于 2019-11-30 02:24:41
I want to simulate Newton's law of universal gravitation using Box2D. I went through the manual but couldn't find a way to do this. Basically what I want to do is place several objects in space (zero gravity) and simulate the movement. Any tips? It's pretty easy to implement: for ( int i = 0; i < numBodies; i++ ) { b2Body* bi = bodies[i]; b2Vec2 pi = bi->GetWorldCenter(); float mi = bi->GetMass(); for ( int k = i; k < numBodies; k++ ) { b2Body* bk = bodies[k]; b2Vec2 pk = bk->GetWorldCenter(); float mk = bk->GetMass(); b2Vec2 delta = pk - pi; float r = delta.Length(); float force = G * mi * mk

How do I apply gravity to my bouncing ball application?

老子叫甜甜 提交于 2019-11-30 02:13:58
I've written a fairly simple java application that allows you to drag your mouse and based on the length of the mouse drag you did, it will shoot a ball in that direction, bouncing off walls as it goes. Here is a quick screenshot: alt text http://img222.imageshack.us/img222/3179/ballbouncemf9.png Each one of the circles on the screen is a Ball object. The balls movement is broken down into an x and y vector; public class Ball { public int xPos; public int yPos; public int xVector; public int yVector; public Ball(int xPos, int yPos, int xVector, int yVector) { this.xPos = xPos; this.yPos = yPos

Manage Layout Inside a Horizontal Oriented Radiogroup

故事扮演 提交于 2019-11-29 23:11:01
I am using a TableLayout with TableRows as my main activity. Inside the TableLayout is a Radio Group containing 2 Radio Buttons inside the activity (the Radio Group being inside a table row). I want to be able to align the rightmost radio button to the right edge screen, so the "gap" is between the left radio button and right button (instead of after the right radio button). i.e. So instead of having | (x) (x) gap | I will have |(x) gap (x)| where (x) are the Radio Buttons and | are the edges of the screen I can use gravity (center_horizontal) to put both the buttons in the middle (i.e. | gap

What is exact difference between gravity and layout_gravity [duplicate]

无人久伴 提交于 2019-11-29 11:54:15
问题 Possible Duplicate: Android - gravity and layout_gravity I have been working on android xml's. I have used android:layout_gravity="center" to align components in specific position. Now a days, when I was working on a Dialog like Activity , I came across android:gravity="center" . What I found there was, gravity was used to align its child to a specific position. I would share an example of what it is, android:gravity="center" <LinearLayout android:layout_width="match_parent" android:layout

Change gravity of PopupWindow

女生的网名这么多〃 提交于 2019-11-29 10:21:37
问题 I have a button that must show a popup window. And the popup window must be aligned with the right side of the button. That's how I do it. button.setOnClickListener( new View.OnClickListener() { @Override public void onClick( final View view ) { if(popup == null) { final View view = getLayoutInflater().inflate(R.layout.popup, null); popup = new PopupWindow(view); } if(popup.isShowing()) { popup.dismiss(); } else { popup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); popup.setFocusable

Gravity in pygame [closed]

不问归期 提交于 2019-11-29 08:35:10
I'm making a platform game with pygame, and I would like to add gravity to it. Right now I only have a picture which moves when I press the arrow keys, and my next step would be gravity. Here's my code: import pygame, sys from pygame.locals import * pygame.init() FPS = 30 fpsClock = pygame.time.Clock() DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32) pygame.display.set_caption("Jadatja") WHITE = (255, 255, 255) catImg = pygame.image.load("images/cat.png") catx = 10 caty = 10 movingRight = False movingDown = False movingLeft = False movingUp = False while True: #main game loop #update