gravity

Gravity with predetermined destination

天大地大妈咪最大 提交于 2019-11-27 07:40:06
问题 I am using gravity in a 2d environment for my game. The objects I use in my game all have x and y coordinates, they can be "thrown" into a level, meaning instantiated, then given a specific origin location and then given new coordinates each frame with the following gravity: public void throwObject(float delta) { setX(getX() + velocity.x * delta); setY(getY() + velocity.y * delta); velocity.y += gravity.y * delta; } with the following: Vector2 GRAVITY = new Vector2(0, -10); From a given

Android Support Design TabLayout: Gravity Center and Mode Scrollable

 ̄綄美尐妖づ 提交于 2019-11-27 06:20:10
I am trying to use the new Design TabLayout in my project. I want the layout to adapt to every screen size and orientation, but it can be seen correctly in one orientation. I am dealing with Gravity and Mode setting my tabLayout as: tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); So I expect that if there is no room, the tabLayout is scrollable, but if there is room, it is centered. From the guides: public static final int GRAVITY_CENTER Gravity used to lay out the tabs in the center of the TabLayout. public static final int GRAVITY_FILL

How to set both gravity and layout gravity of a LinearLayout programatically

落爺英雄遲暮 提交于 2019-11-26 16:56:16
问题 I am risking writing a duplicate question, but as I was researching the answer to another SO question, I realized that I couldn't find a simple question and answer that included setting both gravity and layout_gravity of a LinearLayout . Also, I was confused as to the difference between them when talking about a ViewGroup rather than just a view. I am answering my question below. Here are some of the other questions I viewed: How to set gravity to layout programmatically? Set gravity for

Android Support Design TabLayout: Gravity Center and Mode Scrollable

半世苍凉 提交于 2019-11-26 15:16:08
问题 I am trying to use the new Design TabLayout in my project. I want the layout to adapt to every screen size and orientation, but it can be seen correctly in one orientation. I am dealing with Gravity and Mode setting my tabLayout as: tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); So I expect that if there is no room, the tabLayout is scrollable, but if there is room, it is centered. From the guides: public static final int GRAVITY_CENTER

How set the android:gravity to TextView from Java side in Android

痴心易碎 提交于 2019-11-26 15:08:10
问题 I can use android:gravity="bottom|center_horizontal" in xml on a textview to get my desired results, but I need to do this programmatically. My textview is inside a tablerow if that matters in a relativelayout . I have tried: LayoutParams layoutParams = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); labelTV.setLayoutParams(layoutParams); But if I understand correctly, that would apply it to the tablerow , not the