Android UI属性大解

子控件位置:(XML文件)

LinearLayout中:

        android:layout_gravity= "center"
RelativeLayout中:
http://www.myexception.cn/mobile/455691.html

在class里编写控件位置

eg:
RelativeLayout insertLayout = (RelativeLayout)view1.findViewById(R.id.screen);

RelativeLayout.LayoutParams layoutParams= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);

layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
insertLayout .addView(mapScaleBarView,layoutParams);

使得控件居下靠近边缘显示。




你可能感兴趣的:(Android,studio)