i am working on android api8. i want to position/place a view on screen dynamically. but to use setX and setY we need API level 11 and above. how can we use it in API 8 or is there any alternative for this? need help
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can use http://nineoldandroids.com/ and have API support from level 1, in this way:
You can do this by using the
LayoutParams
. These can be added to components of the android interface to set their bounds and position.An example (setting the LayoutParams on a child view of a RelativeLayout)
Take note that the type of the LayoutParams must be equal to the parent of the childview you want to add them to. (
LinearLayout.LayoutParams
for aLinearLayout
,RelativeLayout.LayoutParams
for aRelativeLayout
etc.).Also, instead of
childView.setLayoutParams(params);
you can also useparentView.addView(childView,params);
to set the Layoutparams when the item is added to the parent container.NOTE! The values for the coordinates are in pixels. Since it's best practice to use DP values to define your interface sizes you could use this piece of code to convert dp to pixels:
aditionally to above(Leon Lucardie's answer)if the view is a GroupView and when its being supposed the view edges to go outside the screen , you also have to put :
to avoid distortions within view's inner layout