动态改变布局
来源:互联网 发布:python 显示 字符集 编辑:程序博客网 时间:2024/06/06 22:39
1.布局文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <android.support.v4.view.ViewPager android:id="@+id/id_guide_viewpager" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:flipInterval="30" android:persistentDrawingCache="animation" /> <FrameLayout android:id="@+id/dot_frame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center" android:layout_marginBottom="16.0dip"> <LinearLayout android:id="@+id/dot_contain" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" > </LinearLayout> <ImageView android:id="@+id/cur_dot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/dot2_w" /> </FrameLayout> <ImageView android:id="@+id/open" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:clickable="true" android:src="@drawable/ic_open" android:visibility="gone" /></RelativeLayout>
讲FrameLayout设置为靠近父控件底部,并水平居中,距离底部距离(bottomMargin)
public void setDotAlignBottom(int px){ View m_obj_view = LayoutInflater.from(context).inflate(R.layout.guide,null); FrameLayout dot_frame = (FrameLayout) m_obj_view.findViewById(R.id.dot_frame); /*****因为FrameLayout的父布局是RelativeLayout 所以类型为 RelativeLayout.LayoutParams****/ RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(dot_frame.getLayoutParams()); /****设置布局位置****/ layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); layoutParams.bottomMargin = px;//or layoutParams.setMargins(0,0,0,px); dot_frame.setLayoutParams(layoutParams); }
代码很简单,不多做介绍;
0 0
- Android动态改变布局
- Android动态改变布局
- Android动态改变布局
- 动态改变代码布局
- Android动态改变布局
- 动态改变布局
- Android动态改变布局
- 动态改变ListView布局
- Android动态改变布局
- ListView 动态改变布局
- 动画-动态改变布局大小
- js 动态改变div内部布局
- 在活动中动态改变布局
- android 动态改变布局控件 的大小
- 动态改变布局到顶部的距离
- 【Android UI】动态改变ListView布局
- 动态改变recyclerview的item的布局
- Android之动态改变布局大小
- umask与文件默认权限
- TreeMap源码分析(red-black树)
- pch文件的配置
- Spring aop 实现异常拦截
- shiro认证的过程
- 动态改变布局
- Java的典型特点
- ssh架构搭建
- python 列举文件夹下文件并排序
- Eclipse安装tomcat插件详解
- notification的几种使用方法
- Java 异常限制
- 【Linux学习笔记】Shell 基础(3) — Shell流程控制语句
- setOnPageChangeListener 过时了